03-Nov-2021 02:28
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.
03-Nov-2021
07:14
- last edited on
21-Nov-2022
15:44
by
JimmyPackets
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.
03-Nov-2021 08:44
03-Nov-2021 08:48
this will be in LTM. You just use countrycode in iRule as mentioned above.
e.g. ES - Spain, CH - Switzerland
03-Nov-2021
08:50
- last edited on
04-Jun-2023
19:16
by
JimmyPackets
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"
}
}
}
04-Nov-2021 02:05
04-Nov-2021
02:45
- last edited on
04-Jun-2023
19:16
by
JimmyPackets
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"
}
}
}
12-Nov-2021 04:00
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
12-Nov-2021 04:43
This isn't issue because of this iRule. Something else is causing the issue. Capture Tcpdump and analyse what is causing the reset.