Forum Discussion

m1tchm8_56526's avatar
m1tchm8_56526
Icon for Nimbostratus rankNimbostratus
Jan 26, 2018

How do i maintain the SSL connection between client and the F5 after login to a web page

I have a BIGIP LTM version 13 which I am using for SSL offload to a web server behind the F5. The SSL offload initially works by maintaining the SSL connection (HTTPS) between the client and F5 and HTTP from the F5 to the web server.

 

The web site has a login page and after logon the page is send back to the client as HTTP but I want the client to maintain a SSL connection after logon.

 

I used the iRule below to notify the web server that this traffic was SSL previously offloaded by the F5 but this has not worked.

 

Basically I need the client and F5 to maintain the SSL connection after logon to the web server. Any help would be appreciated.

 

iRule below:

 

when HTTP_REQUEST { HTTP::header insert "X-Forwarded-Proto" "https"; }

 

7 Replies

  • When you say "...after logon the page is send back to the client as HTTP..." does the web server send the user a redirect to a HTTP page?

     

  • If your web application is forcing a redirect to a hardcoded HTTP page you need to use an iRule to intercept and overwrite the "Location" header in HTTP_RESPONSE for that particular URL.

     

  • Making the assumption that this is a HTTP redirect from http to https the following iRule will replace check the HTTP Location header and if it starts with http:// does a string map to replace with https:// and replaces the Location header with it.

    when HTTP_RESPONSE {
        if {[string tolower [HTTP::header Location]] starts_with "http://" }{
             Generate a new Location destination replacing "http://" with "https://" and replace HTTP Header in response
            HTTP::header replace Location [string map {"http://" "https://"} [HTTP::header "Location"]]
        }
    }
    `
    
    

    You might want to add in a check for the hostname as well if the server sends valid directs to http, e.g. following iRule only replaces updates redirects for the domain :

    `when HTTP_RESPONSE {
        if {[string tolower [HTTP::header "Location"]] starts_with "http://www.abc.com" }{
             Generate a new Location destination replacing "http://" with "https://" and replace HTTP Header in response
            HTTP::header replace Location [string map {"http://" "https://"} [HTTP::header "Location"]]
        }
    }
    
  • Hi,

     

    I think the web server is sending traffic back to the F5 as HTTP but I expected the F5 to maintain the SSL connection back to the client? Well this is what I would like to happen.

     

  • This has to be due to a redirect or link on the web page as the HTTP connection is established from the client side.

     

    If you do not need to connect to the server at all using HTTP then assign the default HTTP to HTTPS redirect iRule (_sys_https_redirect) on the HTTP Virtual Server, this will redirect all HTTP request to the HTTPS Virtual Server.

     

    You can also track the connection using Google Chrome and the Inspect feature, right click on the page select Inspect from the menu. In the Developer Tools window select Network and tick Preserve log option and start.

     

    Go to login page and login to track the journey, expect you to see the change from HTTPS to HTTP as a Redirect (status code 301 or 302) or as a simple new connection from a link, maybe the POST of the login form.

     

  • ensure you have two virtual servers setup on the LTM. The first listening on your preferred https and the second on http. You then need to attached the pre-packaged f5 irule for http-to-https redirect "_sys_https_redirect" to the virtual server listening on http. This has always worked and redirects to the virtual server listening on https.