« BigIP iRule::Disable Trace Method | Main | Oh sure... »

03/03/2008

Another Useful iRule::Redirect based on client IP

Another short but useful irule I put together for those times when a release is going in and you want your external customers to get redirected to a maintenance page while your internal testers can still get into the site in order to validate the release.

when HTTP_REQUEST {
if { ! ([HTTP::uri] contains "/path/to/custom/errors")}{
if { ! ( [IP::addr [IP::client_addr] equals 10.0.0.0/255.0.0.0]) }{
HTTP::redirect https://www.somesite.com/path/to/custom/errors/maintenancePage.html
}}
}


This irule redirects customers unless their client IP matches an internal subnet. The first line prevents a redirect loop from occurring. Whenever we commit a release, this rule gets enabled and works without a hitch. However, because we have lots of internal subnets scattered all over the world and with different partners, continually adding

"or [IP::addr [IP::client_addr] equals X] or ...."


statements can get tedious. So another alternative is to create a class of internal subnets and if the address does not equal one of those internal addresses, redirect.

TrackBack

TrackBack URL for this entry:
https://www.typepad.com/services/trackback/6a01156fbc6fe6970c01157228804a970b

Listed below are links to weblogs that reference Another Useful iRule::Redirect based on client IP:

Comments