Forum Discussion
Geolocation redirection for external published DNS
I received a request to set up a redirection in the bigip depending on where the traffic is coming from. Basically when a customer accesses finder.abc.com(sample) from Spain, it gets redirected to https://www.abc.com/es-es/home/servicepoints.html. or if the access comes from SE, it goes to https://www.abc.com/se-se/home/servicepoints.html. or if the Geolocation is unknown it gets redirected to home.
Is this achievable in F5 bigip? the challenge is that the requests would be coming from external access so assuming that anybody in Spain accesses the URL, then it redirects accordingly.
Appreciate any help.
- spalandeNacreous
You can use something like below
when HTTP_REQUEST { switch -glob [whereis [IP::client_addr]country] { "ES" { HTTP::respond 301 Location "https://www.abc.com/es-es/home/servicepoints.html" } "CH" { HTTP::respond 301 Location "https://www.abc.com/se-se/home/servicepoints.html" } default { HTTP::respond 301 Location "https://www.abc.com/home" } } }
Please check below for selecting country code in iRule accordingly.
- asabadoAltocumulusThanks SanjayP. Pardon my ignorance but this will be implemented in GTM I assume? Or can it be done at LTM level? Do I need to define the countries anywhere first? Get Outlook for Android<>>
- spalandeNacreous
this will be in LTM. You just use countrycode in iRule as mentioned above.
e.g. ES - Spain, CH - Switzerland
- spalandeNacreous
I see you were using SE for Sweden. So iRule would be following
when HTTP_REQUEST { switch -glob [whereis [IP::client_addr]country] { "ES" { HTTP::respond 301 Location "https://www.abc.com/es-es/home/servicepoints.html" } "SE" { HTTP::respond 301 Location "https://www.abc.com/se-se/home/servicepoints.html" } default { HTTP::respond 301 Location "https://www.abc.com/home" } } }
- asabadoAltocumulusThanks SanjayP, I did try out the irules but it didn’t seem to work.. ☹
- spalandeNacreous
F5 has inbuilt gelocation database so this should work. I see there was 1 typo in iRule
(space between [IP::client_addr] country).
Please correct below and also enable some logging and provide the log output if still not working.
when HTTP_REQUEST { switch -glob [whereis [IP::client_addr] country] { "ES" { log local0. "ES IP match: [IP::client_addr]" HTTP::respond 301 Location "https://www.abc.com/es-es/home/servicepoints.html" } "SE" { log local0. "SE IP match: [IP::client_addr]" HTTP::respond 301 Location "https://www.abc.com/se-se/home/servicepoints.html" } default { log local0. "no match: [IP::client_addr]" HTTP::respond 301 Location "https://www.abc.com/home" } } }
- asabadoAltocumulus
Hi SanjayP, thank you for your response. I have tried to modify it based on above given syntax but still doesn't work.
I'm getting site can't be reached and unexpectedly closed the connection. below is the actual link i created.
qsfvcuuqzdxxvdw-dhlfinder-redirection-test.dhl.com
- spalandeNacreous
This isn't issue because of this iRule. Something else is causing the issue. Capture Tcpdump and analyse what is causing the reset.
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