Forum Discussion

Mike_Breeden_61's avatar
Mike_Breeden_61
Icon for Nimbostratus rankNimbostratus
Oct 03, 2008

HTTPS Redirect

I have the following IRule that sets the uri for an address to the following on http requests. What I want is to be able to use the same rule but also have it change from the http to https. My IRule is shown below. Please help

 

 

when HTTP_REQUEST {

 

if {([HTTP::host] equals "myclaytonbenefits.com") and

 

([HTTP::uri] equals "/")}

 

{

 

HTTP::uri "http://myclaytonbenefits.com/SHCM/"

 

}

 

}

3 Replies

  • Arie's avatar
    Arie
    Icon for Altostratus rankAltostratus
    You're only changing the URI that's sent to the server; there is no change on the client side. If you need to change it to https presumably you want to use SSL between the client and the server (rather than just between the Big-IP and the server). In that case you'll want to use a redirect:

     

     

    HTTP::redirect "https://myclaytonbenefits.com/SHCM/"

     

     

    This sends a temporary redirect to the client (302). If you need to use a permanent redirect (301) you need to use HTTP::respond.

     

     

    Keep in mind that redirects cannot be stacked in a single connection; if you have a VS with multiple iRules with redirects you'll run into problems unless you take certain measures.
  • Thanks but I want it to work like this

     

     

    I type in http://www.myclaytonbenefits.com or http://myclaytonbenefits.com and it redirects to https://www.myclaytonbenefits.com/SHCM but displays as https://www.myclaytonbenefits.com in my browser window. I hope this makes sense.
  • We have fixed the issue. We had two virtual servers setup. One was listening on port 80 and the other was on port 443. To get it to work we had to make an IRule for the Virtual server on port 80 to redirect any request to https. Then the IRule on the virtual server listening on port 443 would rewrite the uri correctly.

     

     

    Port 80 IRule:

     

     

    when HTTP_REQUEST {

     

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

     

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

     

    }

     

     

    Port 443 Irule:

     

     

    when HTTP_REQUEST {

     

    if {([HTTP::host] equals "myclaytonbenefits.com" or [HTTP::host] equals "www.myclaytonbenefits.com") and

     

    ([HTTP::uri] equals "/")}

     

    {

     

    HTTP::uri "https://myclaytonbenefits.com/SHCM/"

     

    }

     

    }

     

     

    Hope this helps others and I appreciate your help!!!