Forum Discussion
hooleylist
Aug 19, 2011Cirrostratus
What would you like to redirect requests to if they are to an IP address? Maybe to that same IP, but via HTTPS?
What about requests with no host header value? What would you like to redirect them to? Most browsers set the host header to an IP if that was what was used. But custom clients may not. Do you use public IP addresses for your virtual servers? If so, you could redirect the client to the virtual server IP over https:
when HTTP_REQUEST {
switch -glob [string tolower [HTTP::host]] {
"www.*" {
Host started with "www.". Allow request without redirecting it?
}
"*[a-z]*" {
Host is not null and not an IP address
HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]
}
"" {
Host is null
HTTP::redirect "https://default.example.com[HTTP::uri]"
}
default {
Host is an IP address
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
}
}
If you're not concerned about requests with no host header, you could remove the redirect to the hardcoded hostname.
Aaron