Forum Discussion

scampbell_82082's avatar
scampbell_82082
Icon for Nimbostratus rankNimbostratus
Mar 10, 2008

Rewriting 3xx responses from http to https only for on-site URLs

I started out by using the "Redirect Rewrite All" option in my HTTP profile. However, the Location header in the 3xx HTTP responses was being rewritten from HTTP to HTTPS whether the hostname was on-site or off-site.

 

 

I need a "Redirect Rewrite", but only when a particular hostname is present. I talked to F5 support and they said that I needed to build an iRule.

 

 

Here is my setup:

 

 

client -HTTPS-> myapp.example.com -> BigIP -HTTP-> web server pool

 

 

When the HTTP response code is 3xx and the Location header has the hostname myapp.example.com, I want the Location header to be rewritten from HTTP to HTTPS.

 

 

If the Location header for the 3xx response is some other hostname, such as www.cnn.com, then I want the iRule to leave it alone.

 

 

1 Reply

  • Hi,

     

     

    You need to set up a vs with:

     

    -a clientSSL profile

     

    -a pool with pool member listening on HTTP (port 80?)

     

     

    Here is some template you should check to set up your iRule:

     

     

    when HTTP_RESPONSE {

     

    if {([HTTP::status] starts_with "3") and ([HTTP::header "Location"] equals "myapp.example.com") }{

     

    HTTP::header replace "Location" "https://myapp.example.com"

     

    }

     

    }

     

     

    Some links you should have a look at:

     

    HTTP::header manipulationClick here

     

    Click here