Forum Discussion

deltapez_21676's avatar
deltapez_21676
Icon for Nimbostratus rankNimbostratus
Apr 21, 2008

http to https irule

 

The following irule was added to redirect any HTTP response from the port 80 web servers to HTTPS. It seems to have a recursion problem and will return an extra "s" (HTTPsS://example.com) in the URL.

 

 

when HTTP_RESPONSE {

 

if { [HTTP::status] == "302" } {

 

respond with 302 using original Location value

 

HTTP::respond 302 Location [string map {"http://" "https://"} [HTTP::header Location]]

 

}

 

}

 

 

 

In reviewing the captured headers, the following format is intermittently returned:

 

Location: HTTPsS://example.com

 

 

 

Any suggestions on a better approach that will retain query data, post info, and cookies?

 

 

 

 

 

2 Replies

  • Hi,

    In theory, the string map command should only ever replace http:// with https:// one time. Can you add logging to the rule to see what the Location header value is before you make the change and after?

    
    when HTTP_RESPONSE {
       if { [HTTP::status] == 302" } {
          log local0. "[IP::client_addr]:[TCP::client_port]: Rewriting [HTTP::header Location] to [string map {http:// https://} [HTTP::header Location]]"
           respond with 302 using original Location value
          HTTP::respond 302 Location [string map {"http://" "https://"} [HTTP::header Location]]
       }
    }

    Aaron
  •  

    The log highlighted BigIP as performing correctly. SiteMinder was configured for SSL on ports 80 & 443 creating the extra "s". Fixed. Thanks for your assistance.

     

     

     

    D