Forum Discussion

jch125_41641's avatar
jch125_41641
Icon for Nimbostratus rankNimbostratus
Oct 26, 2010

Referrer from email links

We have a partner that we host a site for and we are applying an iRule that will redirect requests unless the referrer is explicity allowed. Here is the current iRule and it works like I expect it would.

 

 

when HTTP_REQUEST {

 

switch -glob [string tolower [string trim [URI::host [HTTP::header Referer]]]] {

 

"*ReferA.com" -

 

"*ReferB.com" -

 

"*ReferC.com" -

 

"" {

 

pool example1.com

 

}

 

default {

 

Send all other requests to XXX page

 

HTTP::redirect "example2.com"

 

}

 

}

 

}

 

 

It has now been brought to our attention that whenever this partner sends out email campaigns with links to the example1.com site, the referrer ends up being Live.blahblahblah.com (or similar behavior for Gmail or other web-based email clients) and gets sent to the default page (example2.com).

 

Any suggestions what I can do to handle these types of referrers or another string to match on in the HTTP_Request?

 

 

Thanks,

 

John

3 Replies

  • Hi John,

     

     

    I can't think of a simple solution to this issue based on your description. Trying to enumerate all of the possible Referer hostnames that provide webmail doesn't look feasible.

     

     

    Is there any pattern you could use in the URI to match the email campaign URIs? If so, you could add a check on the URI to send traffic to the pool.

     

     

    Also, the redirect value should be a fully qualified URL like http://example2.com. Using "example2.com" will be interpreted as a local reference by the browser and would cause the client to request whatever URL the were redirected from with example2.com appended.

     

     

    Aaron
  • Aaron,

     

    Thank you for the feedback. I agree about trying to enumerate the possible referer hostnames not being feasible. If the partner is able to supply me a URI to match in the email campaign links, what is the best way to include it in my current iRule?

     

     

    Thanks,

     

    John
  • Hi John,

    Within the default switch case, you could add a check for the URI token that is unique to the batch email links. If there is just one token, you could use an 'if' check. If there are more than a couple of links, you could use another switch case:

    
    when HTTP_REQUEST {
       switch -glob [string tolower [string trim [URI::host [HTTP::header Referer]]]] { 
          "*ReferA.com" -
          "*ReferB.com" -
          "*ReferC.com" {
              Do nothing.  The action will be to use the VS's default pool
          }
          default {
    
              No host match.
              Check the requested URI to see if it's a whitelisted URI
             switch -glob [HTTP::uri] {
                "*/batch_email_uri_1/*" -
                "*/batch_email_uri_2/*" {
                    Do nothing.  The action will be to use the VS's default pool
                }
                default {
                    Send all other requests to XXX page 
                   HTTP::redirect "example2.com"
                }
             }
          }
       }
    }
    

    Aaron