Forum Discussion

Sean_Lonning_29's avatar
Sean_Lonning_29
Icon for Nimbostratus rankNimbostratus
Nov 01, 2017

HTTPS to HTTPS on HTTP to HTTPS redirect iRule

I have three scenarios I am trying to create an iRule for. I have two VIP's for one domain, one is HTTP and one is HTTPS. Please advise if there is a better setup for the VIP's if this iRule cannot do what I am seeking it to do.

Scenario 1: -->

Scenario 2: -->

Scenario 3: -->

Scenario 4: --> -- There is no change here, just forwarding the URL unchanged

iRule I have that covers Scenario 1, 3 and 4. Just need some help on Scenario 2

iRule

HTTP_REQUEST {

    if {([HTTP::host] contains "example.domain.local")} then {

        HTTP::redirect "https://example.domain.local[HTTP::uri]"
    }

    elseif {([HTTP::host] contains "example")} then {

    HTTP::redirect "https://example.domain.local[HTTP::uri]"

    }
    else {

        forward
    }

}

6 Replies

  • I would probably split the configuration into two irules. If you apply this one on your 443 VS you'll likely experience and endless redirect loop as your first if statement will be hit everytime and give you a redirect leading you to hit it again.

     

    On your 80 VS you can apply the _sys_https_redir On your 443 VS you can use ([HTTP::host] equals "webappsdev") as your if condition

     

    It should not be necessary to explicitly state the forward part.

     

  • I applied this iRule to both the HTTP and HTTPS vips and all works well. Guess no change is needed

     

  • Okay, then I'd still try the equals instead of contains, it might narrow the result enough not to redirect with the FQDN