Forum Discussion

Eireann78_19953's avatar
Eireann78_19953
Icon for Nimbostratus rankNimbostratus
Sep 16, 2008

Http 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

  • 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
  • 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
  • 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