Forum Discussion

mikeshermanit_2's avatar
mikeshermanit_2
Icon for Nimbostratus rankNimbostratus
Dec 19, 2016

HTTP to HTTPS iRule

I have two VS that share the same IP

 

I have two pools one that contains by back-end servers listening on Port 80 and another that contains the same servers but listening on port 443.

 

How would I write up an iRule that says if anyone types : Http://* please use the pool that is listening on port 443.

 

This way they wont get an error when trying http but will get redirected to https.

 

If there's a better way to do it, I'm also open to suggestions.

 

Thanks!

 

1 Reply

  • Hamish's avatar
    Hamish
    Icon for Cirrocumulus rankCirrocumulus

    Use the _sys_https_redirect rule on the HTTP VS's.

    It's literally

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

    Oh, and remove the pool from the HTTP VS.