Forum Discussion
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.
- Sean_Lonning_29
Nimbostratus
Heinrichm - What is up there works, the part I need to get to work is -->
- Sean_Lonning_29
Nimbostratus
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
- Sean_Lonning_29
Nimbostratus
Looks like you are right on the endless loop part too..
- Arun_LK_202176
Nimbostratus
could you provide how you used the iRUle for https.
Recent Discussions
Related Content
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com