Forum Discussion
Srinivasan_G_31
Nimbostratus
Jun 06, 2012GEO Based redirect
Friends,
I need help on getting an iRule that performs redirect to a specific web page based on client browser's country of access/GEO information. If the user accesses the website from Asia i want to detect that information from the HTTP packet and redirect it to the APAC webpage on the web-server. Can you help me out here. Thanks a lot.
Srini
7 Replies
- hoolio
Cirrostratus
Hi Srinivasan,
You can use the whereis and HTTP::redirect or HTTP::uri commands to do this:
https://devcentral.f5.com/wiki/iRules.whereis.ashx
https://devcentral.f5.com/wiki/iRules.http__redirect.ashx
https://devcentral.f5.com/wiki/iRules.http__uri.ashx
Do you want to rewrite the URI to hide the change from the client or redirect the request so the client sees the change? Do you want to change the hostname and/or URI?
Aaron - Srinivasan_G_31
Nimbostratus
Hi Aaron,
Thanks for your post. I would probably want to hide the info from the client. Basically what i would like to do is match a country in an iRule and redirect it to a different webpage instead of redirecting it to a pool. I would also probably like to rewrite the URI if that is an option.
Srini - Srinivasan_G_31
Nimbostratus
Hi Aaron,
Also would like to know if GTM functionality is required to support the Whereis feature.
Srini - hoolio
Cirrostratus
whereis is supported in 10.1 or higher for LTM. Here's an example of rewriting the URI based on the country code:when CLIENT_ACCEPTED { Save the country code once per connection set cc [whereis [IP::client_addr] country] } when HTTP_REQUEST { Check if the cc is not empty if {$cc ne ""}{ Insert the country code in the requested URI HTTP::uri "/${cc}[HTTP::uri]" } }
Aaron - Richard__HarlanHistoric F5 AccountI would use a switch statement for the HTTP_REQUEST. That way you will not have to create a country web page for each country out there. With the switch statement you will add all the country's you have webpages for then send the rest to the default page what ever it is.
- Srinivasan_G_31
Nimbostratus
Thanks Richard. I would like to have a sample iRule that accomplishes this as i am no iRule expert. Can you help here? - Srinivasan_G_31
Nimbostratus
Hi Aaron,
For using "whereis" do we need to install the geographic IP database into the system?
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects