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
You 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
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