Forum Discussion
BIGIP LTM GeoLocation Redirection
Hello,
I am somewhat new to the LTM still and learning the power of the tool. We are deploying a new virtual server which needs to detect and redirect various GeoLocations to a different URI, for example US redirects to https://example.com/US from https://example.com/. Based on the documentation I have designed this iRule:
when HTTP_REQUEST {
set country [whereis [IP::client_addr] country]
if {$country eq "US"}{
HTTP::redirect "https://example.com/US"
return
} else if {$country eq "UK"}{
HTTP::redirect "https://example.com/UK"
return
} else if {$country eq "CA"}{
HTTP::redirect "https://example.com/CA"
return
} else {
return
}
}
My biggest concern is example.com returned correctly? Eg I can access example.com as long as I not in the US, CA or UK? Also I don't expect it but there shouldn't be any issues with looping, correct? IE WHEN HTTP_REQUEST is only checked once per request, and not again after redirecting.
Regards,
GM
- Leonardo_SouzaCirrocumulus
It will be looping, the HTTP_REQUEST happens for every HTTP request, so the new request will trigger the iRule again, and another redirect.
Add an if to check the path, if equal / do the logic.
https://devcentral.f5.com/wiki/irules.http__path.ashx
Also, change the ifs to a switch, as it is easy to expand in the future.
https://devcentral.f5.com/wiki/irules.switch.ashx
Recent Discussions
Related Content
* 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