Forum Discussion
Auto redirect http to https for LB traffic
For traffic routing to the new LB solution, if there is no matching host on the HTTP endpoint, return a redirect to the client for them to try the same request on the HTTPS endpoint.....this is for a list of poolnames if that makes a difference
- DAGOATMAMBA_328
Nimbostratus
- Im trying to create this as an Irule
- Hamish
Cirrocumulus
There's a standard iRule (_sys_https_redirect) provided by F5 for this. Unless you're doing this to learn, or you require some additional functionality, I would recommend you use that.
- Hamish
Cirrocumulus
Sorry, I missed that extra bit. It should be easy too. Chuck an extra iRule in ahead of the _sys_https_redirect. If you don't want the redirect to happen, then disable further events on that connection and force a close after the current request completes.
- DAGOATMAMBA_328
Nimbostratus
when HTTP_REQUEST { Check if Host header has a value if {[HTTP::host] eq ""}{ pool pl_autos.dev.test.com } else { HTTP::redirect https://[HTTP::host][HTTP::uri] }
}
- DAGOATMAMBA_328
Nimbostratus
This is what I have come up with.....So, it looks for the host that has no matching host header for the pool and if it doesnt have matching one it redirects it at the end to https with the same hostsS/
- DAGOATMAMBA_328
Nimbostratus
Am I somewhere in the ballpark (boy im a newb)
- DAGOATMAMBA_328
Nimbostratus
Anyone has a different Irule that'll work for if you no host is found for a poolname and redirect it to https? o
- Hectorm
Nimbostratus
when HTTP_REQUEST { create a variable and change it everything to lowercase set Vuri [ string tolower [HTTP::uri]] set Vheader [string tolower [HTTP::host]] assign a pool name to the variable set Poolname "pl_www.testpool.org_80" set Irulename "Irule_www.testpool.org_80" Checking if the pool has active pools memebers set Poolmember [active_members $Poolname ] set Poolmemberlist [ active_members -list $Poolname] If there are no active pool members send it to outservice splash page if {$Poolmember < 1} then { log local0.alert "ALERT-TEAM Pool $Poolname is down. This mean website site is down. IRULE=$Irulename"; HTTP::redirect "http://www.outservicepage.org."; } else { set list of host to match. if none of them match redirect to HTTPS switch $Vheader { testpool.org { pool $Poolname } { pool $Poolname }
default {HTTP::redirect "https://[HTTP::host][HTTP::uri]"} } }
}
- Hectorm
Nimbostratus
when HTTP_REQUEST {
create a variable and change it everything to lowercase set Vuri [ string tolower [HTTP::uri]] set Vheader [string tolower [HTTP::host]] assign a pool name to the variable set Poolname "pl_www.testpool.org_80" set Irulename "Irule_www.testpool.org_80" Checking if the pool has active pools memebers set Poolmember [active_members $Poolname ] set Poolmemberlist [ active_members -list $Poolname] If there are no active pool members send it to outservice splash page if {$Poolmember < 1} then { log local0.alert "ALERT-TEAM Pool $Poolname is down. This mean website site is down. IRULE=$Irulename"; HTTP::redirect "http://www.outservicepage.org." } else {
set list of host to match. if none of them match redirect to HTTPS
switch $Vheader { testpool.org { pool $Poolname } www.testpool.org { pool $Poolname } default {HTTP::redirect "https://[HTTP::host][HTTP::uri]"} } }
}
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