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...
zbirmingham
Nov 17, 2011Nimbostratus
I guess I need to test this 1st to see what I want to do with requests that don't have this header set. I have copied what you have above and changed it so it will only pick up on a certain URI. It will also display the state you are in if you are not MO or IL.
If I want it to lookup the client I and i can use this:
when HTTP_REQUEST {
if { ([string tolower [HTTP::uri]] starts_with "/testingpage") } {
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" {
HTTP::respond 200 content "Your IP IS from MO or IL"
}
default {
set state [whereis $client_ip abbrev]
HTTP::respond 200 content "Your IP IS NOT MO or IL you are $state"
}
}
}
}
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