cancel
Showing results for 
Search instead for 
Did you mean: 

Geolocation redirection for external published DNS

asabado
Altocumulus
Altocumulus

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.

 

8 REPLIES 8

SanjayP
MVP
MVP

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.

 

https://support.f5.com/csp/article/K4034

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

this will be in LTM. You just use countrycode in iRule as mentioned above.

 

e.g. ES - Spain, CH - Switzerland

SanjayP
MVP
MVP

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" } } }

 

Thanks SanjayP, I did try out the irules but it didn’t seem to work.. ☹

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" } } }

 

asabado
Altocumulus
Altocumulus

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

This isn't issue because of this iRule. Something else is causing the issue. Capture Tcpdump and analyse what is causing the reset.