Forum Discussion
Rewriting multiple values of HTTP Location header
Hello,
Thanks for your answer.
In fact, I need to replace a reverse proxy with the F5, currently with LTM.
The problem I'm having is the rewriting of the RESPONSE and specifically the Location Header.
For the HTTP request rewriting I was able to rewrite it with "internalhost" and internal uri/path to the back-end webserver.
The problem I'm having in the Response redirects coming from the back-end that I need to rewrite with external host + adapt some path and query params ( within the same redirect location )
How can I do that ?
for exemple :
Http location received from the back-end that need to be rewrited to
http://internalhost/SASPortal/public http://ExternalHost/analytics/Portal/public
http://internalhost/SASPortal/test?myparam=http%3ASASPortal... http://internalhost/SASPortal/test?myparam=http%3%2F%2Fanalytics%2FPortal...
http://internalhost/SASTheme/mytheme http://ExternalHost/Theme_extranal/mytheme
I also need to rewrite the referer with the external uri and some relative path in the location
For the Content rewriting of the response, I 'm using a stream profile and this is ok . But I'm having a lot of problems with the rewriting of the Location header.
many thanks in advance for your future answers.
Regards
Frédéric
Hi Frédéric,
Can you add default stream profile to vs and try this iRule?
when HTTP_REQUEST {
STREAM::disable
if { [HTTP::host] eq "externalhost" } {
HTTP::host "internalhost"
switch -glob [HTTP::uri] {
"/analytics/Portal*" { HTTP::uri [string map {"/analytics/Portal" "/SASPortal"} [HTTP::uri]] }
"/Theme_extranal*" { HTTP::uri [string map {"/Theme_extranal" "/SASTheme"} [HTTP::uri]] }
}
}
}
when HTTP_RESPONSE {
if { [HTTP::header exists "Location"] } {
HTTP::header replace Location [string map [list "internalhost" "externalhost" "/SASPortal" "/analytics/Portal" "/SASTheme" "/Theme_extranal" "/valuefrominternal/" "/valuetoexternal/"] [URI::decode [HTTP::header Location]]]
}
STREAM::expression {@internalhost@externalhost@}
STREAM::enable
}
Recent Discussions
Related Content
* 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