Forum Discussion
Jeroen_V_95572
Aug 17, 2011Nimbostratus
Outgoing header modification
Hello All,
I have a little problem on a BIG IP ASM v10 system.
I have created the following irule:
when HTTP_REQUEST {
set uri [HTTP::uri]
}
when HTTP_RESPONSE {
if { [HTTP::header "Location"] starts_with "http://www.backendserver.com"} {
set host "https://www.example.be"
HTTP::header replace "Location" $host$uri}
}
The Irule compiles and works but when I browse to e.g http://www.example.be/parameter1 it hits this Irule.
But The if statement was never matched because when you enter parameter1 then the www.example.be server responds and not the back end server.
Does anybody know an easier way to replace a part of the location header ?
Thanks in advance !
Regards
J
- hooleylistCirrostratusHi Jeroen,
when HTTP_REQUEST { set uri [HTTP::uri] } when HTTP_RESPONSE { log local0. "[IP::client_addr]:[TCP::client_port]: URI: $uri, status: [HTTP::status], Location: [HTTP::header "Location"]" if { [HTTP::is_redirect] and [HTTP::header "Location"] starts_with "http://www.backendserver.com"} { set host "https://www.example.be" HTTP::header replace "Location" $host$uri log local0. "[IP::client_addr]:[TCP::client_port]: Rewriting Location to $host$uri" } }
- Jeroen_V_95572NimbostratusHi Aaron,
- Jeroen_V_95572NimbostratusHi Aaron,
- hooleylistCirrostratusSorry, I just realized the protocol wasn't prepended to the Location header. So the browser interprets it as a local URI which it appends to the requested protocol, host and URI. If you use this it should work:
when HTTP_REQUEST { set uri [HTTP::uri] set host [HTTP::host] } when HTTP_RESPONSE { log local0. "[IP::client_addr]:[TCP::client_port]: URI: $uri, status: [HTTP::status], Location: [HTTP::header "Location"]" if { [HTTP::is_redirect] and [HTTP::header "Location"] starts_with "http://www.backendserver.com"} { HTTP::header replace "Location" "https://$host$uri" log local0. "[IP::client_addr]:[TCP::client_port]: Rewriting Location to https://$host$uri" } }
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