Forum Discussion
GEOIP redirection irule
I got timeout error message
Pls help me to resolve the issue.
when HTTP_REQUEST {
if { [[[string tolower [HTTP::host]] equals "www.example.com"] AND [[HTTP::uri] starts_with "" ]] }
{ Parse the client IP from the CDN header
set client_ip [HTTP::header value "Client-IP"]
if { $client_ip eq "" }{
The header was empty/did not exist, so use the actual client IP
set client_ip [IP::client_addr]
}
switch [whereis $client_ip abbrev] {
"AF" {
Afganistan
HTTP::redirect "http://www.example.com/home-af"
}
"BH" {
Bahrain
HTTP::redirect "http://www.example.com/home-bh"
}
"BD" {
Bangladesh
HTTP::redirect "http://www.example.com/home-bd"
}
"BE" {
Belgium
HTTP::redirect "http://www.example.com/home-be"
}
"EG" {
Egypt
HTTP::redirect "http://www.example.com/home-eg"
}
"FR" {
France
HTTP::redirect "http://www.example.com/home-fr"
}
"DE" {
Germany
HTTP::redirect "http://www.example.com/home-de"
}
"IN" {
India
HTTP::redirect "http://www.example.com/home-in"
}
"IR" {
Iran
HTTP::redirect "http://www.example.com/home-ir"
}
"IQ" {
Iraq
HTTP::redirect "http://www.example.com/home-iq"
}
"IT" {
Italy
HTTP::redirect "http://www.example.com/home-it"
}
"JO" {
Jordon
HTTP::redirect "http://www.example.com/home-jo"
}
"KZ" {
Kazakhastan
HTTP::redirect "http://www.example.com/home-kz"
}
"KE" {
kenya
HTTP::redirect "http://www.example.com/home-ke"
}
"KW" {
Kuwait
HTTP::redirect "http://www.example.com/home-kw"
}
"LB" {
Lebanon
HTTP::redirect "http://www.example.com/home-lb"
}
"MO" {
Morocco
HTTP::redirect "http://www.example.com/home-ma"
}
"NP" {
Nepal
HTTP::redirect "http://www.example.com/home-np"
}
"NL" {
Netherlands
HTTP::redirect "http://www.example.com/home-nl"
}
"OM" {
Oman
HTTP::redirect "http://www.example.com/home-om"
}
"PK" {
Pakistan
HTTP::redirect "http://www.example.com/home-pk"
}
"QA" {
Qatar
HTTP::redirect "http://www.example.com/home-qa"
}
"RU" {
Russia
HTTP::redirect "http://www.example.com/home-ru"
}
"SA" {
Saudi Arabia
HTTP::redirect "http://www.example.com/home-sa"
}
"ES" {
Spain
HTTP::redirect "http://www.example.com/home-es"
}
"LK" {
Sri Lanka
HTTP::redirect "http://www.example.com/home-lk"
}
"SD" {
Sudan
HTTP::redirect "http://www.example.com/home-sd"
}
"SZ" {
Switzerland
HTTP::redirect "http://www.example.com/home-sz"
}
"SY" {
Syria
HTTP::redirect "http://www.example.com/home-sy"
}
"TN" {
Tunisia
HTTP::redirect "http://www.example.com/home-tn"
}
"TR" {
Turkey
HTTP::redirect "http://www.example.com/home-tr"
}
"UA" {
Ukraine
HTTP::redirect "http://www.example.com/home-ua"
}
"AE" {
United Arab Emirates
HTTP::redirect "http://www.example.com/home-ae"
}
"YE" {
Yemen
HTTP::redirect "http://www.example.com/home-ye"
}
"ZZ" {
Redirect all others
HTTP::redirect "http://www.example.com/home"
}
}
}
else {
pool example_web_pool
}
}
Regards
insitha
- hooleylistCirrostratusHi insitha,
when HTTP_REQUEST { if { [string tolower [HTTP::host]] equals "www.example.com" && [HTTP::path] eq "/" }{ Parse the client IP from the CDN header set client_ip [HTTP::header value "Client-IP"] if { $client_ip eq "" }{ The header was empty/did not exist, so use the actual client IP set client_ip [IP::client_addr] } set country [string tolower [whereis $client_ip abbrev]] switch $country { "af" - "bh" - "bd" - "be" - "eg" - "fr" - "de" - "in" - "ir" - "iq" - "it" - "jo" - "kz" - "ke" - "kw" - "lb" - "mo" - "np" - "nl" - "om" - "pk" - "qa" - "ru" - "sa" - "es" - "lk" - "sd" - "sz" - "sy" - "tn" - "tr" - "ua" - "ae" - "ye" { HTTP::redirect "http://www.example.com/home-${country}" } default { Redirect all others HTTP::redirect "http://www.example.com/home" } } } else { pool example_web_pool } }
- THASINNimbostratusthanks a lot . it is working fine.
- hooleylistCirrostratusHi Thasin,
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