Forum Discussion
Jason_Andres_40
Nimbostratus
Sep 27, 2007switch http to https if header contains "SSL" =1
I'm trying to create an iRule to switch HTTP to HTTPS if the HEADER contains SSL=1.
In our coldfusion code we insert in the the Header the name SSL with a value of 1 when someone clicks through to a page that requires SSL. If the page doesn't require SSL then the Header doesn't have the name SSL.
Rule to run on HTTP VS
when HTTP_RESPONSE {
if { [HTTP::header "SSL"] == 1 } {
if { [TCP::local_port] == 80 } {
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
Rule to run on HTTPS VS
when HTTP_RESPONSE {
if { [HTTP::header "SSL"] <> 1 } {
if { [TCP::local_port] == 443 }} {
HTTPS::redirect http://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
}
- Colin_Walker_12Historic F5 AccountI'm not sure you'd need the second rule if you're only trying to redirect to SSL , but the first one looks sound.
- Jason_Andres_40
Nimbostratus
I'm using the editor with this code and I can't save it, the editor list errors in invalid arguments and missing {[}. - Andy_Herrman_22
Nimbostratus
Looks like you have one missing } in the first irule and a misplaced } in the second one.when HTTP_RESPONSE { if { [HTTP::header "SSL"] == 1 } { if { [TCP::local_port] == 80 } { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } } } when HTTP_RESPONSE { if { [HTTP::header "SSL"] <> 1 } { if { [TCP::local_port] == 443 } { HTTPS::redirect http://[getfield [HTTP::host] ":" 1][HTTP::uri] } } }
Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects