nich_66940
Sep 27, 2007Nimbostratus
Rewriting 302 redirects
We have come 'intelligent' website code that redirects the user to SSL pages based on what the developer originally thought best.
As we are using SSL offloading on the BigIP this has meant that we need to set the redirect to http to stop the site from performing infinite loops as the site detects that the BigIP has sent the request to port 80, despite the fact that the contention is acceptably secured.
So what I want to do is intercept 302 redirects from the site that match certain URLs and rewrite them to https.
Ie if a redirect from the site tells the user to connect to http://example.com/secure/* I want to redirect it to https://example.com/secure/*
Using the profile option in LTM profiles creates other problems with pages that really should be redirected to port 80.
Going through previously published results I assume I want to do some magic like:
when HTTP_RESPONSE {
if { [HTTP::status] == "302" } {
if { [HTTP::header exists "Location"] } {
if { string compare -nocase -length 26 [HTTP::header "Location"] "http://example.com/secure/" == 0} {
HTTP::header replace "Location" [echo [HTTP::header "Location"] | regexp s/http/https ]
}
}
}
}
Any help is greatly appreciated.
nich.
update: more guesses on my behalf for code needed