Forum Discussion
zbirmingham
Nov 17, 2011Nimbostratus
iRule redirect via Geolocation
I'm looking to implement an iRule that leverages geolocation to redirect certain traffic from specific states. Since we leverage a CDN, I will need to use the X-Forwarded-For field for the incoming IP...
hooleylist
Nov 17, 2011Cirrostratus
Note in the above example, I've set it so client requests without the Client-IP header will be redirected. How would you want to handle these requests? Would you want to look up the actual client IP instead? If so, you can try this:
when HTTP_REQUEST {
Parse the client IP from the CDN header
set client_ip [HTTP::header value "Client-IP"]
if { $client_ip eq "" }{
The header was empty/did not exist, so use the actual client IP
set client_ip [IP::client_addr]
}
switch [whereis $client_ip abbrev] {
"MO" -
"IL" {
Do nothing and allow the request
}
default {
Redirect all others
HTTP::redirect "http://www.example.com/
}
}
}
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