Forum Discussion

Marker_58065's avatar
Marker_58065
Icon for Nimbostratus rankNimbostratus
Dec 15, 2010

Append domain when needed and redirect to HTTPS

Here is the background - we have a couple of internal F5s with a bunch of applications that we are doing SSL offloading on. When users access these applications they don't have to type the FQDN because of a dns search suffix. So if a user types 'sharepoint' in the browser, it resolves 'sharepoint.ourdomain.net' but the host header only has 'sharepoint' and not the FQDN. We like to use one general rule for redirecting to HTTPS on our virtuals when possible. We use the following rule external:

 

 

when HTTP_REQUEST {

 

HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri]

 

}

 

 

Which works great with a FQDN, but we would like to have something similar that looks to see if the the host request has the FQDN and if not, append it, then redirect to HTTPS. Here is something i have come up with, but I wanted to know if maybe there is a better way.

 

 

when HTTP_REQUEST {

 

switch -glob [string tolower [HTTP::host]] {

 

*.ourdomain.net {

 

HTTP::redirect https://[HTTP::host][HTTP::uri]

 

} default {

 

HTTP::redirect https://[HTTP::host].ourdomain.net[HTTP::uri]

 

}

 

}

 

}

 

 

Today we just build a custom redirect irule per application, but we would like a generic one we can apply across multiple virtuals. Any feedback you would have would be great.

 

Thanks.