Forum Discussion
Anthony
Nimbostratus
May 04, 2017Why would a request seemingly by-pass the F5
Hi all, I'm troubleshooting an issue at the moment where an iRule triggers and redirects the request as expected, but sometimes it doesn't and the user/browser see's the original page that was reques...
Anthony
Nimbostratus
May 05, 2017Thanks for your replies. Yes the Virtual does have a one-connect profile on.
@abdul rahman - what may be in my dns sometimes? Can you elaborate a bit on this please?
Here is the iRule in quesiton (some urls changed due to sensitivity)
priority 101
when HTTP_REQUEST
{
log local0. "Working on: [HTTP::uri]"
if { [TCP::local_port] equals "443" } {
set scheme "https"
} else {
set scheme "http"
}
if { [HTTP::path] eq "/" } {
if { [HTTP::query] contains "Silo=Type" } {
Silo Override
} else {
Set variable defaults
set client_ip "0.0.0.0"
log local0. "client_ip set to 0.0.0.0"
Check for existing LocaleCookie
if { [HTTP::cookie exists "LocaleCookie"] }
{
log local0. "LocaleCookie exists... extracting data"
Extract country from locale
example: market=GB&locale=en_GB&language=en&country=GB
set country [findstr [HTTP::cookie value "LocaleCookie"] "country%3D" 10 2]
Extract the language (for WCS sites only)
set language [findstr [HTTP::cookie value "LocaleCookie"] "language%3D" 11 2]
log local0. "set country = $country & language = $language from LocaleCookie"
} else {
set client_ip [IP::client_addr]
log local0. "client_ip set to $client_ip"
Get the client IP from the XFF header if available (testing override)
Un-comment to enable
if { [HTTP::header exists "XFF"] } {
log local0. "XFF present - values: [HTTP::header values "XFF"]"
set client_ip "[getfield [HTTP::header values XFF] " " 1]"
set client_ip [getfield [lindex [HTTP::header values XFF] 0] "," 1]
log local0. "client ip extracted from XFF is $client_ip"
}
set country [whereis $client_ip country]
Use country as language (for WCS sites only)
set language [string tolower $country]
log local0. "set country = $country & language = $language from LookUp"
if { [string length $country] == 0 } {
set country "UNKNOWN"
log local0. "country set to UNKNOWN"
}
if { [class match -- $country equals EU_Countries] } {
log local0. "Found EU country: $country"
set country "EU"
}
}
switch $country
{
"GB" { set location "/locale/country?country=GB" }
"ZA" { set location "/locale/country?country=ZA" }
"IE" { set location "/locale/country?country=IE" }
"US" { set location "/locale/country?country=US" }
"CA" { set location "/locale/country?country=CA" }
"EU" { set location "/eu/en" }
"FR" { set location "/fr/$language" }
"IT" { set location "/it/$language" }
"ES" { set location "/es/$language" }
"UNKNOWN" { set location "/country-selection" }
default { set location "/locale/country?country=AV" }
}
log local0.debug "XFF=[HTTP::header values X-Forwarded-For] IP=$client_ip C=$country LOC=$location"
log local0. "redirecting to: $scheme://[HTTP::host]$location"
HTTP::redirect "$scheme://[HTTP::host]$location"
return
event disable all
}
} else {
set locale [string range [HTTP::path] [expr {[string first "/" [HTTP::uri]] +1}] 8]
set url [string range [HTTP::uri] [expr {[string first "/" [HTTP::uri]] +10}] end]
set checkurl [string range $url 0 [expr {[string first "/" $url] }] ]
if { ([class match -- $locale equals cs_markets]) } {
set newlocale [class search -value cs_markets equals $locale]
log local0. "Got locale: $locale - translated to newlocale: $newlocale"
log local0. "Got remaining URL: $url | checkurl: $checkurl"
if { not ([class match -- $checkurl equals cs_exception_urls]) and
$url != "dummy-url1" and
$url != "dummy-url2" and
$url != "dummy-url3" } {
log local0. "Redirecting to $scheme://[HTTP::host]/$newlocale/$url"
HTTP::redirect "$scheme://[HTTP::host]/$newlocale/$url"
log local0. "Redirecting to $scheme://[HTTP::host]/$newlocale"
HTTP::redirect "$scheme://[HTTP::host]/$newlocale"
event disable all
} else {
log local0. "Either class (not) matched, or xxxx URL : $url"
}
}
}
}
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