Forum Discussion
Eireann78_19953
Nimbostratus
Sep 16, 2008Http to Https from HTTP_RESPONSE
Hi,
I am having an issue where I re-direct traffic to a VIP and use a class profile to change this to https.
This works fine but unfortunately the app then responds using http so to save our devs time I want to look at each HTTP_RESPONSE from this VIP and convert it to https.
I think I know how to do the redirect (see below) just not sure what else I need to do to get it to match all.
when HTTP_RESPONSE {
{ HTTP::redirect "https://[HTTP:host][HTTP:uri]" }
}
Any help much appreciated,
E
4 Replies
- hoolio
Cirrostratus
Hi darraghk,
The concept of the rule snippet you listed wouldn't work as the HTTP::host and HTTP::uri commands won't return values in in the serverside context (like HTTP_RESPONSE). And if it did, you'd be redirecting the client to https for the same host and URI they just requested, not where the application is directing them for the next request.
Does the app send references to https in the Location header of redirects or within the payload? If it's in redirects, you should be able to use the rewrite redirects option on the HTTP profile. Or if you need to add more logic than the default config options you could use an iRule that looks for HTTP::is_redirect and checks/modifies the Location header. If it's references to https in the response payload, you could use a stream profile and iRule to modify it.
For more info on the HTTP profile option for rewriting redirects, try searching askF5.com for 'rewrite redirects'. For info on using an iRule to rewrite redirects, check the iRule Codeshare. And for examples of using a stream profile to rewrite response content, check the iRule wiki page for STREAM::expression.
Aaron - Eireann78_19953
Nimbostratus
Hi Aaron,
This was actually part 1 and requires the location header to be re-written. I was then to look at a second issue of re-writing the references in the payload I was investigating the stream profile for this.
Thanks for the info I will take a look in the codeshare etc. and post back if I have any problems.
Cheers,
Darragh - Eireann78_19953
Nimbostratus
Hi,
Just to close this off I used the rewrite redirects option on the http profile and it worked but ended up breaking other traffic that didn't need to be re-written. I used the iRule below to match on a URL basis.
when HTTP_RESPONSE {
if {[HTTP::is_redirect] and [HTTP::header value Location] contains "http://blah.test.xxx"}{
HTTP::header replace Location [string map {http: https:} [HTTP::header value Location]]
}
}
Thanks for your help,
D - hoolio
Cirrostratus
Good to hear you got it working.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
