iRule that redirects client to FTP from HTTP if downloading file greater than 10 MB

Hello.

I would like to write an iRule that redirects client from HTTP to FTP while downloading file larger than 10MB. Could you help me please? This doesn’t work at all:

when HTTP_RESPONSE {

if {[HTTP::header exist “Content-Length”] && [HTTP::header “Content-Length”] >= 10485760 && [HTTP::header “Content-type”] contains “application” }{

HTTP::redirect “ftp://user1:useruser@192.168.0.10[HTTP::header “Content-Location”]”

}

}

Thank you in advance

Peter

I got it to work. It looks like this right now:

when HTTP_REQUEST {

if { [HTTP::uri] ends_with “.exe”}{

set uri [HTTP::uri]

log “here1”

}

}

when HTTP_RESPONSE {

if {[HTTP::header “Content-Length”] >= 1048576 && [HTTP::header “Content-type”] contains “application” }{

HTTP::redirect “ftp://user1:useruser@192.168.0.1:21$uri”

log “here2”

}

}

The only problem is that before the download from FTP start it takes about 1 minute for BIG-IP to process (I’m using virtual edition). Logs are generated immidiately and I’m confused why redirect isn’t sent immidiately too. After analysing tcpdump on server side it seems that BIG-IP is downloading whole file first before user is redirected to FTP server. How to fix it or how should I do this properly?

Please help me guys.

You could try the following…

HTTP::response 302 Location "ftp://user1:useruser@192.168.0.1:21$uri" Connection Close

Not sure if it will help but its worth a try.

Kevin

Can’t edit my post above… stupid website. Had a typo.

HTTP::respond 302 Location “ftp://user1:useruser@192.168.0.1:21$uri” Connection Close

Kevin

Follow that with:

TCP::close

return

when HTTP_RESPONSE {

if {[HTTP::header “Content-Length”] >= 1048576 && [HTTP::header “Content-type”] contains “application” }{

HTTP::respond 302 Location “ftp://user1:useruser@192.168.0.1:21$uri” Connection Close

log “here2”

TCP::close

return

}

}