Forum Discussion
Nathan_Bultman_
Oct 24, 2009Historic F5 Account
Header replacement assistance
Problem:
When a request comes in, if it has the header MyHeader (regardless of value), we need to change the Referer header value, from http://domain.com/path/object to https://domain.com/path/object
I've tried to accomplish this with:
when HTTP_REQUEST {
if {[HTTP::header exists "MyHeader"]} {
HTTP::header replace Referer [ https://domain.com[HTTP::uri ] ]
}
}
Then sending a request:
GET /index.html HTTP/1.1
host: 1.1.1.1
MyHeader: foo
Referer: http://domain.com
But I'm seeing the same referer header on the request when it egresses the LTM.
I'm a relative noob on iRules, so this might be something simple. Am I using 'Exists' correctly?
Thanks in advance.
- hoolio
Cirrostratus
Hi Nathan,when HTTP_REQUEST { log local0. "[IP::client_addr]:[TCP::client_port]: New [HTTP::method] request to [HTTP::host][HTTP::uri]\ with Referer [HTTP::header Referer]" if {[HTTP::header exists "MyHeader"]} { log local0. "[IP::client_addr]:[TCP::client_port]: Updating Referer to\ [string map -nocase {http:// https://} [HTTP::header Referer]" HTTP::header replace Referer "[string map -nocase {http:// https://} [HTTP::header Referer]" } } when HTTP_REQUEST priority 501 { log local0. "[IP::client_addr]:[TCP::client_port] (501): Current Referer [HTTP::header Referer]" }
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