Forum Discussion

Adam_Fint_1489's avatar
Adam_Fint_1489
Icon for Nimbostratus rankNimbostratus
Aug 02, 2011

HTTP::Querry matching referal?

I have a BigIP running 9.4.7 HF2 (it is scheduled to be upgraded to 10.x in a month or two). I have an iRule who's behavior does not make sense to me, but I fairly new to iRules.

 

 

when HTTP_REQUEST {

 

switch -glob [string tolower [HTTP::query]] {

 

"*db_oem_id*" {

 

HTTP::respond 301 Location "http://[HTTP::host][HTTP::path]"

 

}

 

default {

 

nothing

 

}

 

}

 

}

 

 

 

Basically, I'd like to see if the HTTP query (the part of the URL after the ?) contains db_oem_id, and if so, redirect back to the same page, but without any query at all. This works for the most part; however, if you are coming FROM an external page that has db_oem_id in it, the F5 is still redirecting, based (I'm guessing) on the Referer (which then causes an infinite loop). This behavior seems odd to me. Am I doing something wrong? The below is from a Wireshark capture.

 

 

 

GET / HTTP/1.1

 

Accept: image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-ms-application, application/x-ms-xbap, application/vnd.ms-xpsdocument, application/xaml+xml, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*

 

Referer: http://www.goxxx.com/ViewArticle.dbml?DB_OEM_ID=500&ATCLID=205178399&KEY=&DB_OEM_ID=500&DB_LANG=C&IN_SUBSCRIBER_CONTENT=

 

Accept-Language: en-us

 

User-Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; FunWebProducts; GTB7.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; AskTbAD2/5.9.1.14019)

 

Accept-Encoding: gzip, deflate

 

Host: www.shopgoxxx.com

 

Connection: Keep-Alive

 

Cookie: ASP.NET_SessionId=jn2xr0ezkbj4fa55ksxa0v45; ffSource=; usrPref=05c8440c-4b0e-44ca-bd25-d01419d4d5e2; BIGipServerFFPartners-Pool=RVM6E8bLwY+TvJjRrm9lOpnLtsM/K95zeoCmTACDxaJVEZkxXi/0AOebYRZpW8MVeL8C1JSpkg==; TLTHID=81A4036943F9D99CE96669BC9EF7017D; TLTSID=5F63163649E1ACC53E3FA990701A2843; __utmc=255568202; __utma=255568202.747088971.1311879674.1311879674.1311879674.1; __utmz=255568202.1311879674.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=255568202.|1=psid=08779=1

 

 

 

HTTP/1.0 301 Moved Permanently

 

Location: http://www.shopgoxxx.com/

 

Server: BigIP

 

Connection: Keep-Alive

 

Content-Length: 0

 

 

 

 

4 Replies

  • It should not be using the Referrer information unless you specifically direct it to.

     

     

    I would suggest adding in some logging to detect and log what the iRule is seeing and causing this behavior.

     

     

    log local0. "Match Found: Host - [HTTP::host], Path - [HTTP::path], Query - [HTTP::query]"

     

     

    Add this in above the HTTP::respond and look in your LTM Log to see what is going on.
  • Hi Adam,

    You could be explicit as to which external site is accessing this iRule

    For example

    
    when HTTP_REQUEST {
      if {[HTTP::host] eq "www.domain.com" } {
        switch -glob [string tolower [HTTP::query]] {
          "*db_oem_id*" {  HTTP::respond 301 Location "http://[HTTP::host][HTTP::path]" }
        }
      }
    }
    

    I hope this helps along with Michael Yates excellent suggestion.

    Bhattman

  • There was another iRule being applied to this same vip:

     

     

    - rule shopgoxxx.com {

     

    - when HTTP_REQUEST {

     

    - switch -glob [HTTP::host] {

     

    - "www.shopgoxxx.com" {

     

    - return

     

    - }

     

    - default {

     

    - HTTP::respond 301 Location "http://www.shopgoxxx.com[HTTP::uri]"

     

    - return

     

    - }

     

    - }

     

    - }

     

    - }

     

     

    When we combined the iRule in my first post along with the above into the one iRule, everything started working as expected; previously they were each applied to the VIP, and we'd get a 301 loop.