Forum Discussion
Sam_Parkes_1110
Nimbostratus
Dec 18, 2006Redirect rewrite stopped working
Hi,
We run an interface where clients POST XML strings to us via https, and we run all our certificate handling on the F5, so only forward http (non-SSL) traffic, one of our servlets responds with a redirect, but bases the redirection on the incoming URL - seen by the app as 'http' but our client may have posted theri request via SSL. To get around this we wrote a rule based upon one found on your site.
At first throughout testing it worked very well, and we implemented this into our Production systems, again this worked consistently for a few weeks. Then, out of nowhere, it seems, the iRule just will not work, though no-one has edited this iRule since implementation.
Any ideas why this happenned? Is there something wrong with this rule:
when RULE_INIT {
F5 iRule for performing rewriting of
- HTTP-response 'Location' headers
(redirect rewrite's)
Define Redirect Rewrite rules here
set ::redirect_rewrite [list "http://mysite.com/mycontext/MyRedirectedServlet https://mysite.com/mycontext/MyRedirectedServlet" "http://mysite.com:443/mycontext/MyRedirectedServlet https://mysite.com:443/mycontext/MyRedirectedServlet"]
}
when HTTP_RESPONSE {
check if redirect (HTTP status 3xx)
and 'Location:' header exists...
return immediately if
there is nothing to rewrite
if { [HTTP::status] starts_with "302" } {
set location [HTTP::header "Location"];
if { $location == "" } {
return;
}
} else {
return;
}
check all 'ProxyPassReverse' entries..
and 'break' when first match is found...
log LOCAL0.info "Location: $location (check for rewrites)";
foreach x $::redirect_rewrite {
set a [getfield $x " " 1];
log LOCAL0.info " ? starts_with '$a' ... ";
if { $location starts_with $a } {
set b [getfield $x " " 2];
log LOCAL0.info "...yes, replace '$a' with '$b'";
set len [string length $a];
set tmp [substr $location $len];
set location "${b}${tmp}";
log LOCAL0.info "Location: $location";
HTTP::header replace "Location" $location;
break;
}
}
}
Any help would be very much appreciated,
Thanks,
Sam.
- Colin_Walker_12Historic F5 AccountFirst, I don't see anything glaringly wrong with your iRule at first look. More importantly, there's little chance that this iRule would just suddenly stop working. I would imagine that something either in the configuration on your BIG-IP, the iRule, or the traffic being sent has changed, otherwise the behavior wouldn't be inconsistent with what you've already seen.
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