Forum Discussion
RoyalM_205794
Dec 14, 2015Nimbostratus
GeoIP iRule redirects with switch
Hi All,
I'm trying to create an 'all-in-one' iRule to handle a few things at once. Firstly I need to allow a few whitelists through (CDN, office addresses etc) then based on the GeoIP location redi...
Kai_Wilke
Dec 14, 2015MVP
Hi RoyalM,
I would structure and format the code in this way...
when HTTP_REQUEST {
if {[class match [string tolower [HTTP::header value "Via"]] contains CDN_HEADERS] } then {
return
} elseif {[class match [IP::client_addr] equals Whitelist] } then {
return
} else {
switch -exact -- [whereis [IP::client_addr] country] "NL" {
pool NL-splash
} "RU" {
pool RU-splash
} "UK" {
HTTP::respond 301 noserver Location "https://www.google.com"
} "US" {
HTTP::respond 301 noserver Location "https://www.google.com"
} default {
return
}
}
}
Give it a try, maybe its already resolving your issues?
Cheers, Kai
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