Forum Discussion

metagraphica_25's avatar
metagraphica_25
Icon for Nimbostratus rankNimbostratus
Apr 11, 2017
Solved

iRule to redirect http and https to https over port 8888

I'm Definitely new to writing iRules. Trying to build one iRule to apply to 2 VIPs. One VIP listens on port 80 the other on port 443. The iRule would redirect any normal HTTP or HTTPS traffic to H...
  • Kevin_Davies_40's avatar
    Apr 12, 2017

    Updated code with corrections...

     

    when HTTP_REQUEST { 
        if { [HTTP::host] equals "zzzzzz.xyz.com" or [HTTP::host] equals "zzzzzz.xyz.com"} { 
            HTTP::redirect "https://zzzzzz.xyz.com:8888" 
        }
    }

    What you want is..

     

    when HTTP_REQUEST {
       switch [HTTP::host] {
          "xxxxxx.xyz.com" -
          "yyyyyy.xyz.com" -
          "zzzzzz.xyz.com" { HTTP::redirect https://[HTTP::host]:8888[HTTP::uri] }
       }
    }

    The "-" means use the action of the following condition. So all of the hosts listed will redirect to same hostname on port 8888.