Forum Discussion
Aug 13, 2015
Most likely your issue is the "TCP::local_port". Check out the docs for an example with all the values:
https://devcentral.f5.com/wiki/iRules.TCP__local_port.ashx
You'll likely want to use [TCP::Local_port clientside] if you are looking for the front end VIPs port. Omitting the "clientside" is the same as using "serverside".
This potentially should work (haven't tested it thought)
when HTTP_REQUEST {
if {([string tolower [HTTP::host]] starts_with "www.")} {
HTTP::redirect "https://[string range [HTTP::host] 4 end][HTTP::uri]"
return
} elseif { [TCP::local_port clientside] == 80 } {
HTTP::redirect https://[HTTP::host][HTTP::uri]
return
}
}
Beyond that, I'd recommend adding in some log statements and making sure the values you are expecting to match on are working as you expect.