e.g.
config
[root@ve11a:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
when HTTP_REQUEST {
if { [HTTP::host] eq "testssl.mydomainmail.co.uk" } {
switch [string tolower [HTTP::path]] {
"/" {
HTTP::redirect "https://testssl.mydomain.co.uk/login"
}
default {
HTTP::redirect "https://testssl.mydomain.co.uk[HTTP::uri]"
}
}
} elseif { [HTTP::host] eq "testssl.mydomain.co.uk" } {
switch -glob [string tolower [HTTP::path]] {
"/login" -
"/???lz/*" {
HTTP::redirect "https://testssl.mydomain.co.uk[HTTP::uri]"
}
}
}
}
}
test
[root@ve11a:Active:In Sync] config curl -I http://testssl.mydomainmail.co.uk
HTTP/1.0 302 Found
Location: https://testssl.mydomain.co.uk/login
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve11a:Active:In Sync] config curl -I http://testssl.mydomainmail.co.uk/anythingbhabhabha
HTTP/1.0 302 Found
Location: https://testssl.mydomain.co.uk/anythingbhabhabha
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve11a:Active:In Sync] config curl -I http://testssl.mydomain.co.uk/login
HTTP/1.0 302 Found
Location: https://testssl.mydomain.co.uk/login
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve11a:Active:In Sync] config curl -I http://testssl.mydomain.co.uk/123lz/anythingbhabhabha
HTTP/1.0 302 Found
Location: https://testssl.mydomain.co.uk/123lz/anythingbhabhabha
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
e.g.
config
[root@ve11a:Active:In Sync] config tmsh list ltm rule qux
ltm rule qux {
when HTTP_REQUEST {
if { [HTTP::host] eq "testssl.mydomainmail.co.uk" } {
switch [string tolower [HTTP::path]] {
"/" {
HTTP::redirect "https://testssl.mydomain.co.uk/login"
}
default {
HTTP::redirect "https://testssl.mydomain.co.uk[HTTP::uri]"
}
}
} elseif { [HTTP::host] eq "testssl.mydomain.co.uk" } {
switch -glob [string tolower [HTTP::path]] {
"/login" -
"/???lz/*" {
HTTP::redirect "https://testssl.mydomain.co.uk[HTTP::uri]"
}
}
}
}
}
test
[root@ve11a:Active:In Sync] config curl -I http://testssl.mydomainmail.co.uk
HTTP/1.0 302 Found
Location: https://testssl.mydomain.co.uk/login
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve11a:Active:In Sync] config curl -I http://testssl.mydomainmail.co.uk/anythingbhabhabha
HTTP/1.0 302 Found
Location: https://testssl.mydomain.co.uk/anythingbhabhabha
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve11a:Active:In Sync] config curl -I http://testssl.mydomain.co.uk/login
HTTP/1.0 302 Found
Location: https://testssl.mydomain.co.uk/login
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
[root@ve11a:Active:In Sync] config curl -I http://testssl.mydomain.co.uk/123lz/anythingbhabhabha
HTTP/1.0 302 Found
Location: https://testssl.mydomain.co.uk/123lz/anythingbhabhabha
Server: BigIP
Connection: Keep-Alive
Content-Length: 0
Thanks very much for this, will test.
That worked partially: Any traffic to http://testssl.communigatormail.co.uk gets redirected to https://testssl.communigator.co.uk/login - Doesn’t work Any traffic to http://testssl.communigatormail.co.uk/anything gets redirected to https://testssl.communigator.co.uk/anything (where “anything” could be any URL) - Doesn’t work Any traffic to http://testssl.communigator.co.uk/login gets redirected to https://testssl.communigator.co.uk/login - Works Any traffic to http://testssl.communigator.co.uk/xxxlz/ anything gets redirected to https://testssl.communigator.co.uk/xxxlz/ anything (where xxx can be anything) - Works I’m wondering if switch -glob should be used in the earlier command?
That worked partially: Any traffic to http://testssl.communigatormail.co.uk gets redirected to https://testssl.communigator.co.uk/login - Doesn’t work Any traffic to http://testssl.communigatormail.co.uk/anything gets redirected to https://testssl.communigator.co.uk/anything (where “anything” could be any URL) - Doesn’t work Any traffic to http://testssl.communigator.co.uk/login gets redirected to https://testssl.communigator.co.uk/login - Works Any traffic to http://testssl.communigator.co.uk/xxxlz/ anything gets redirected to https://testssl.communigator.co.uk/xxxlz/ anything (where xxx can be anything) - Works I’m wondering if switch -glob should be used in the earlier command?
Because everything is getting redirected to the same HTTPS URL, you could probably simplify this by simply evaluating the URI.
when HTTP_REQUEST {
if { [HTTP::uri] equals "/" } {
HTTP::redirect "https://testssl.communigator.co.uk/login"
} else {
HTTP::redirect "https://testssl.communigator.co.uk[HTTP::uri]"
}
}