We have been using the standard HTTP redirect irule, (posted below) that comes with our LTM, ver 10.2.0, for sometime now. However I’m being told now that this not only needs to be applied to incoming traffic, but internal traffic coming from the server as well. Basically I need the HTTP redirect iRule to work for all directions no matter where the request is coming from.
Currently we setup two VIPs, one http and the other https. The LTM acts as the SSL offload for a few Apps, the traffic on the backend to the server is done over http. We simply use the http redirect to https.
Should I simply apply this iRule to my https VIP as well or is there a better way to redirect internal traffic to use HTTPS?
when HTTP_REQUEST {
if { [HTTP::host] equals "" } {
reject
}
}
Thanks,
Bob
If you want to redirect HTTP traffic to HTTPS you can use an iRule which redirects all requests to HTTPS:
when HTTP_REQUEST {
HTTP::redirect "https://[HTTP::host][HTTP::uri]"
}
If you want to avoid cert mismatch errors based on hostname you could create an HTTP to HTTPS redirect rule which is specific to the virtual server and then hardcode the hostname:
when HTTP_REQUEST {
HTTP::redirect "https://www.example.com[HTTP::uri]"
}
1.) The rule that you posted does not do any redirecting, it is blocking requests that have no hostname (which would be impressive, because a request with no hostname should never make it to your VIP to start with)
2.) What would you want to redirect things to from & to when dealing with requests from the internal network?
Ok..we found our issue, it actually turned out to be a jquery file that was only effecting older browsers, (IE7). Basically what was happening was that the end users were being prompted to display non secure content and my dev thought because the Content Location in the header referred back to the http address and not the https address that was the issue. However I pretty much ruled that out by applying the rule below. The Content Location in the header is optional so it doesn’t adverserly affect anything by removing it, but what I’d like to do is setup a rule that if the content header says http to be redirected to use https. Any thoughts on that?
when HTTP_RESPONSE {
if { [HTTP::header exists "Content-Location"] } {
HTTP::header remove "Content-Location"
}
}