Forum Discussion

Robert_Crandall's avatar
Robert_Crandall
Icon for Nimbostratus rankNimbostratus
Mar 31, 2008

Detecting https in HTTP_REQUEST

 

I want to do a redirect of a home page, for example:

 

 

www.abc.com to www1.abc.com.

 

 

Looking at previous forums it was suggested that something like the following will work:

 

 

if {[HTTP::host] equals "www.abc.com"} {

 

if { [HTTP::uri] equals "/" } {

 

HTTP::redirect "http://www1.abc.com" }

 

}

 

}

 

 

This looks simple enough, but how can I detect if www.abc.com is coming in via https to redirect to https accordingly?

 

 

Thanks,

 

Bob
  • Colin_Walker_12's avatar
    Colin_Walker_12
    Historic F5 Account
    The only way you'd be able to inspect the data in the packet, if the connection is HTTPS, is if you set up a ClientSSL profile to decrypt the data at the BIG-IP. This would allow you to inspect normally, and then pass the information on. You can re-encrypt it if necessary.

     

     

    Colin
  • Hi,

     

     

    
    when CLIENT_ACCEPTED {
     if { [TCP::local_port] equals "80" } {
        SSL::disable
    }
    when HTTP_REQUEST {
      if {[HTTP::host] equals "www.abc.com"} {
        if { [TCP::local_port] equals "80" } {
          HTTP::redirect "http://www1.abc.com" }
        } elseif { [TCP::local_port] equals "443" }
          HTTP::redirect "https://www1.abc.com"
        } 
      }
    }

     

     

    This code would work if the BIGIP is the SSL termination of the BIGIP Otherwise you would not be able to check the data inside the flow.

     

     

    If this is the case then you won't be able to send HTTP flow or you'll need to disable the SSL flow. you can do so with the SSL::disable command
  • I updated my post due to some mistake i did ... that's what's happening when doing something else at the same time !