Forum Discussion

David_Oertli_18's avatar
David_Oertli_18
Icon for Nimbostratus rankNimbostratus
Mar 27, 2017

HTTP referer header redirect

I am trying to come up with a "sorry server" logic for a virtual server. There is no pool behind the VIP and the only time client requests will hit the virtual server is in the case that there is no healthy real servers. The mechanism I will use to provide that is priority group activation and not part of my question. The question I have is the iRule logic that will meet the below requirements.

1) If special client connects with a 'Referer' HTTP header containing value specialsso.special.com the request will be redirected to special-client downpage

2) If generic client connects with a 'Referer' HTTP header containing any other value than above the request will be redirected to generic-client downpage

3) If any client connects without a 'Referer' HTTP header the request will be redirected to generic-client downpage.

Here is what I have so far:

when HTTP_REQUEST { 
if { [HTTP::header exists "Referer"] } {
        if { [HTTP::header Referer] equals "specialsso.special.com" } {
  HTTP::redirect https://www.site.com/special-client/?
            }
            else   {
            HTTP::redirect https://www.site.com/generic-client
            }
        }
else { HTTP::redirect https://www.site.com/generic-client
}

}

Thanks in advance for the response!

-David O.

1 Reply

  • (Untested). You can have simple if-else statement like this:

    when HTTP_REQUEST { 
    if { ([HTTP::header exists "Referer"]) and ([URI::host [HTTP::header value Referer]] contains "specialsso.special.com") } {
    HTTP::redirect https://www.site.com/special-client/
    } else {
    HTTP::redirect https://www.site.com/generic-client
    }
    }