Forum Discussion

jkeyser_44143's avatar
jkeyser_44143
Icon for Nimbostratus rankNimbostratus
Aug 12, 2009

Help with irule to re-write http to https and keep uri

I have a virtual server listening on 443 and using ssl. The pool that this points to uses http over port 8080. When a user hits the LTM virtual server they get redirected by the nodes in the pool to http and a new URI. The address bar shows the redirect as desired but the protocol is now HTTP instead of HTTPS. Simply putting https into the browser address bar corrects the problem.

 

 

for example.

 

user goes to https://host

 

the response they get back is http://host/uri

 

I need the response they get back as https://host/uri

 

 

 

What is a simple I rule that I can use that will take the HTTP response that the node gives, convert it to https and keep the URI that the node directed the user to. I have tried the simple redirect on HTTP_REQUEST script below but it does not work.

 

 

Any help?

 

 

when HTTP_REQUEST {

 

HTTP::redirect https://[getfield [HTTP::host] ":" 1]

 

}

1 Reply

  • That rule does not preserve the URI so every request would be redirected to just the domain name.

    You probably just need to enable Rewrite Redirects in the http profile, or you can also use a stream profile to change all the http:// strings in the response to https://.

    But you could also use:

     
     when HTTP_REQUEST { 
     HTTP::redirect https://[HTTP::host][HTTP::uri] 
     } 
     

    on a port 80 vip so anything coming in as 80 would be redirected to https.

    Denny