Is there a preferred method of detecting HTTP vs. HTTPS on an incoming request to an F5 load-balancer? We are attempting to detect secure vs. non-secure with an iRule and pass a corresponding header flag along to my web servers.
Here's what we have so far (untested):
when HTTP_REQUEST_SEND {
clientside {
if {[TCP::local_port] == 443} {
HTTP::header replace HTTP_X_FORWARDED_PROTO "https"
}
else {
HTTP::header replace HTTP_X_FORWARDED_PROTO "http"
}
}
}
As you can see, we are using if {[TCP::local_port] == 443} { ... }
to detect SSL, but it feels clunky with the port hard-coded into the rule. Is there a better way?
Perhaps inspecting: SSL::mode
, HTTP:uri
, or something else?