Forum Discussion

viper_113332's avatar
viper_113332
Icon for Nimbostratus rankNimbostratus
Aug 30, 2010

http to https redirect default switch back.........

Hi All,

 

 

am using the below irule to redirect specific "http" sites to "https", i need to add a switch that will help me direct back to HTTP as well, this could be a default switch. can any body help me in that. actually what i need from the switch is to direct back to HTTP in case the user choose any other path than those specified in the irule. at the moment once a user is redirected to https he keeps browsing the website in https and i need to change it to be http.

 

 

when HTTP_REQUEST {

 

 

log local0. "path [HTTP::path]"

 

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

 

 

use -regexp options

 

switch -regexp [string tolower [HTTP::path]] {

 

 

use .* or other reqex expression for the traffic y want to capture "/rado.*" {

 

log local0. "HTTP_REQUEST switch match"

 

HTTP::redirect ""

 

}

 

}

 

 

Kind regards

 

 

 

  • Hello Viper,

     

     

    It sounds like to me that you would need to have one iRule on the HTTP VIP handling the redirects to HTTPS where you need to and then have one iRule on your HTTPS VIP that redirects back over to your HTTP VIP for those specific paths you mentioned. You would need to configure both so that you don't end up creating a loop, but I don't see why you couldn't do that.
  •  

    Hello Naladar,

     

     

    redirection from http to https is done only for the specified path. but acctually i need to extend my irule to use TCP port 80 for all other requested paths. this is because i need the website to be HTTP by default except couple of paths which include a login that should be encrypted.

     

     

    example:

     

     

    when HTTP_REQUEST {

     

     

     

     

    log local0. "path [HTTP::path]"

     

     

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

     

     

     

     

    use -regexp options

     

     

    switch -regexp [string tolower [HTTP::path]] {

     

     

    "/test1.*"

     

    {log local0. "HTTP_REQUEST switch match"

     

    HTTP::redirect "https://www.site.com/ar/services/test1.asp"}

     

     

    "/test2.*"

     

    {log local0. "HTTP_REQUEST switch match"

     

    HTTP::redirect "https://www.site.com/ar/services/test2.asp"}

     

     

    default

     

     

    {

     

    if any other request is initiated then the client TCP port will switch back to port 80. thus the users browser will direct back to http.

     

    }