Forum Discussion
Kalpesh_48932
Nimbostratus
Feb 13, 2012Http_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..
13 Replies
- hoolio
Cirrostratus
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 - Kalpesh_48932
Nimbostratus
HI Hoolio,
I have to use HTTP_Referrer..not HTTP_Header..
Please tell me if i can use HTTP_Referrer in above iRule - nitass
Employee
Please tell me if i can use HTTP_Referrer in above iRulewhat do you want to do?? - nitass
Employee
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? - hoolio
Cirrostratus
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 - Kalpesh_48932
Nimbostratus
I would like to call HTTP_refered header of one of the link to the another one after redirection... - nitass
Employee
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? - Kalpesh_48932
Nimbostratus
•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. - Kalpesh_48932
Nimbostratus
"sorry i could not catch you. can you show us an example?"
example for you nitass..pls help on this ;) - nitass
Employee
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
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
