Hi guys,
I have three domains (a, b and c) and i want to redirect first two of them (a,b) to the last (c), also force http to https for all of them.
I put together below rule which works but I wonder how this can be simplified
this works for all cases except http://c
if { [HTTP::host] eq "a" or [HTTP::host] eq "b"} {
HTTP::redirect "https://c[HTTP::uri]"
return
}
this is to force http://c to https://c
elseif {([TCP::local_port] == 80) and [HTTP::host] equals"c"}{
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
return
}
Thank you
Are you using separate VS for port 80 and another VS for 443 ? If so, you can use something like this:
when HTTP_REQUEST {
HTTP::redirect "https://c[HTTP::uri]"
}
I am assuming that VS1:80 is for handling the 3 domains ONLY i.e., no other domain relies on that VS1:80. If you have multiple domains relying on VS1:80, you can use something like this:
when HTTP_REQUEST {
switch -glob [HTTP::host] {
"a" -
"b" -
"c" { HTTP::redirect "https://c[HTTP::uri]" }
}
Although you end up with 2 VS, I think this is a cleaner way to configure the F5 and it effectively restricts access to port 80 & 443 on the VS.
Hi,
irule provided by Odaah must not be enabled on HTTPS virtual server, if you enable it, browser will loop. yours manage tcp local port filter on c domain.
when HTTP_REQUEST {
switch -glob [HTTP::host] {
"a" -
"b" { HTTP::redirect "https://c[HTTP::uri]" }
"c" {
if {[TCP::local_port] == 80} {
HTTP::redirect "https://c[HTTP::uri]"
}
}
}
}