Forum Discussion

Anthony's avatar
Anthony
Icon for Nimbostratus rankNimbostratus
May 04, 2017

Why 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 requested. I have logging on which outputs the request and when this issue occurs there is no logged request. There are other iRules on the VS, but none of which come into play on this request.

 

Can someone suggest what might be going on here?

 

Many thanks,

 

Anthony

 

  • nathe's avatar
    nathe
    Icon for Cirrocumulus rankCirrocumulus

    you may be best served posting your irule here too, in case there are improvements to be suggested or DCers see issues. Also, do you use OneConnect?

     

  • as long as the request hits the VS, an asscoiated irule will be triggered and the request is modified based upon the irule. may be in your dns sometimes, its forwarding directly to server instead of the VS.

     

  • Thanks 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"
                }
            }
        }
    }
    
  • Hi,

    event disable all
    disable all irule events for next requests in the same TCP connection.

    if you use this command in irule (or in any other irules enabled on the same VS), you won't be able to evaluate this irule for next requests.

  • Just to clarify - adding

    TCP::close
    after the
    event disable all
    was the solution here.