Forum Discussion
mlamutt_62697
Nimbostratus
Feb 03, 2010Redirect HTTP to HTTPS with IP exclusions
I am writing an iRule to allow HTTP access for a select set of IPs while forcing all other traffic to https. This is what I have come up with, but it is not working. Apologies in advance, as this is...
hoolio
Cirrostratus
Feb 03, 2010The syntax error is in the IP::addr closing braces and the unescaped new line between the IP::addr commands. Also, you can check the client IP in CLIENT_ACCEPTED and redirect in HTTP_REQUEST to save checking the client IP on every request:
when CLIENT_ACCEPTED {
Check if the client IP is in the two internal ranges
if { [IP::addr [IP::client_addr] equals 10.0.0.0/8] or \
[IP::addr [IP::client_addr] equals 172.16.0.0/16]} {
Dont redirect the client
set redirect 0
} else {
set redirect 1
}
}
when HTTP_REQUEST {
if {$redirect}{
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects