Forum Discussion

mika's avatar
mika
Icon for Cirrus rankCirrus
Sep 23, 2020

Redirection http to https

Hello, Need helps

So, I want to redirect my host http to https.

To do , I tried the different soltions propoesed by F5 such as :

the irule :

when HTTP_REQUEST {

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

     if {[HTTP::has_responded]}{return}

     log local0. "[HTTP::host] [HTTP::uri]"

     HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"

     regsub -all {:\d*$} [HTTP::host] "" host

     HTTP::redirect https://$host[HTTP::uri]

     return

   

  }

}

 

and:

when HTTP_REQUEST {

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

{  HTTP::respond 301 Location "https://[HTTP::host][HTTP::uri]"}

}

 

and

when HTTP_REQUEST {

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

{  HTTP::redirect "https://[HTTP::host][HTTP::uri]"}

}

 

I also tested the policy LTM.

in both test, I got the same probleme : so the redirection don't work in some browser : for few minutes i get an error conexion reset.

 

if one of you has ever had to deal with this , please tell me what to do !

best regards,

  • Don't see issue on iRule. I suspecting issue on something else.

     

    Did your application works with https?

    • Try to validate via https://abc.com on browser
    • Validate the connectivity from F5 device via curl command
    • I would encourage to use F5 provided redirection irule "_sys_https_redirect" rather then fancy.

     

    Hope it will help to isolate the issue.