Forum Discussion
zbirmingham
Nimbostratus
Nov 17, 2011iRule 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...
hoolio
Cirrostratus
Nov 17, 2011You can use an iRule like this then:
when HTTP_REQUEST {
Parse the client IP from the CDN header
set client_ip [HTTP::header value "Client-IP"]
if { $client_ip eq "" }{
set redirect 1
} else {
switch [whereis $client_ip abbrev] {
"MO" -
"IL" {
Do nothing and allow the request
set redirect 0
}
default {
Redirect all others
set redirect 1
}
}
}
if {$redirect}{
HTTP::redirect "http://www.example.com/
}
}
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
