Http_referrer in iRule

Can anyone tell me how to use HTTP_Referrer in iRule…?

I have my current rule is

when HTTP_REQUEST { if {[active_members [LB:erver pool]] < 1} { HTTP::redirect “http://dev-sorry-webarch.xyz.com” } }

and is working fine for re-direction..but I need to use HTTP_Referrer in it..

Hi Kalpesh,

You can get the value of the referer header (or any other HTTP header) using [HTTP::header value Referer].

http://devcentral.f5.com/wiki/iRules.http\_\_header.ashx

Note that any HTTP header value can be spoofed by a malicious client. And most HTTP user agents will not send a referer if they are coming from an HTTPS site.

Aaron

HI Hoolio,

I have to use HTTP_Referrer..not HTTP_Header..

Please tell me if i can use HTTP_Referrer in above iRule

Please tell me if i can use HTTP_Referrer in above iRulewhat do you want to do??

I have to use HTTP_referrer in it…, i would like to have as http_referrer (which is used for that : http://en.wikipedia.org/wiki/HTTP\_referer) wth the original DNS calledoh, this is what you want, isn’t this?

anyway, i wonder even bigip is able to send http referer header in http response, will browser include it in next request?

An HTTP user agent will likely ignore a Referer header that the server sets in a response. The client is responsible for setting the Referer header based on the URL which generated the request. See RFC2616 for details on this (or the wikipedia link Nitass linked to).

Aaron

I would like to call HTTP_refered header of one of the link to the another one after redirection…

I would like to call HTTP_refered header of one of the link to the another one after redirection…sorry i could not catch you. can you show us an example?

•When a user reaches the VIP via http://dns1.com for which application is down, he must be redirected to http://dns2.com

•On this dns2.com service, we will display a “sorry-page” depending on the original URL entered (dns1.com). For this we need the info either

oVia HTTP_REFFERER HTTP header (http://en.wikipedia.org/wiki/HTTP\_referer) which will contain ‘http://dns1.com’ value (but it looks like F5 removes this information)

oVia a GET parameter : user must be redirected to http://dns2.com/?origin=http://dns1.com , where origin parameter is the original URL entered by the user.

“sorry i could not catch you. can you show us an example?”

example for you nitass..pls help on this :wink:

i do not think HTTP Referer is applicable.

this is an example of the second one.

[root@ve1023:Active] config  b virtual bar list
virtual bar {
   snat automap
   pool foo
   destination 172.28.19.79:80
   ip protocol 6
   rules myrule
   profiles {
      http {}
      tcp {}
   }
}
[root@ve1023:Active] config  b pool foo list
pool foo {
   monitor all fake
   members 200.200.200.101:80 {}
}
[root@ve1023:Active] config  b rule myrule list
rule myrule {
   when HTTP_REQUEST {
   if {[active_members [LB::server pool]] < 1}{
      HTTP::redirect "http://dns2.com/?origin=http://[HTTP::host][HTTP::uri]"
   }
}
}

[root@ve1023:Active] config  b pool foo|grep -i pool\ member
+-> POOL MEMBER foo/200.200.200.101:80   inactive,down

[root@ve1023:Active] config  curl -I http://dns1.com/whatever
HTTP/1.0 302 Found
Location: http://dns2.com/?origin=http://dns1.com/whatever
Server: BigIP
Connection: Keep-Alive
Content-Length: 0

can you please give configuration of iRule to do at GUI mode

when HTTP_REQUEST {
   if {[active_members [LB::server pool]] < 1}{
      HTTP::redirect "http://dns2.com/?origin=http://[HTTP::host][HTTP::uri]"
   }
}

:smiley:

its working thanks for your answer