What is the best way to turn on HTTP Strict Transport Security on an IIS 7 web server?
Can I just through the GUI and add the proper HTTP response header or should I be using appcmd and if so what switches?
|
What is the best way to turn on HTTP Strict Transport Security on an IIS 7 web server? Can I just through the GUI and add the proper HTTP response header or should I be using appcmd and if so what switches? |
|||
|
|
IIS has the ability to add custom headers to responses. This would seem to be the easiest way to go about it. According to the documentation on IIS.net you can add these headers through IIS Manager:
|
|||||
|
|
To supplement voretaq7's answer, you could also do this using the Web.config file — add a block as follows:
Obviously, you may already have a If you wanted to handle the HTTP-to-SSL redirection, as Greg Askew mentioned, you might find it easier to do that with a separate website in IIS. This is how we handle requiring SSL for some client sites. That site contains only an HTTP redirect and some information-disclosure fixes, all in the Web.config:
This is our preferred solution for a couple of reasons — we can easily log redirected traffic separately (as it's in a different IIS log), it doesn't involve more code in the Global.asax.cs (we don't have any code in there, which is a little more convenient for an Umbraco site) and, importantly, it means that all the config is still held in our GIT repo. |
||||
|
|
|
I would use the example from the Wikipedia link you referenced and perform the activity in global.asax for the site. This enables redirecting the request to an https url, and then insert the header into the response. This is due to the HSTS header must be ignored if it isn't in an https response.
|
|||
|
|