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 redirect to either a pool or a different domain.
I have the iRule working in a sense but for a reason unknown to me, redirecting to pools doesn't work - and may be related to how I've laid out the iRule.
I have to include the switch because some of the Virtual Servers this applies to will need 10+ redirect entries to different websites, as does the elseif statements displaying content from the relevant pools. Although, if this works in the switch statement that will be easier to manage but I've tried to include pools in the switch statement and again, no joy.
Basically, if it's not CDN and it's not in the whitelist > Redirect to a new URL or an active Pool based on the client IP.
when HTTP_REQUEST {
set countries [whereis [IP::client_addr] country]
if {[class match [string tolower [HTTP::header value "Via"]] contains CDN_HEADERS] } {
return
} elseif {[class match [IP::client_addr] equals Whitelist]} {
return
} elseif {($countries equals "NL")} { pool NL-splash
} elseif {($countries equals "RU")} { pool RU-splash
} else {
switch [whereis [IP::client_addr] country] {
"UK" { HTTP::respond 301 noserver Location "https://www.google.com" }
"US" { HTTP::respond 301 noserver Location "https://www.google.com" }
default {
return
}
}
}
}
Thanks