Thursday, January 10, 2013

Configuring host headers for https binding

The IIS Management UI only lets you configure host headers for the http protocol (binding). Wondering what host header is? Check the following abstract taken from wikipedia
The "Host" header distinguishes between various DNS names sharing a single IP address, allowing name-based virtual hosting. While optional in HTTP/1.0, it is mandatory in HTTP/1.1.

However, while the UI is not letting you doing it, it does not mean you cannot! And actually, it is really easy to do as long as you can open a command prompt. The trick is to use the magical Appcmd.exe tool, which allows you to do almost anything in IIS. The following command line shows how to add a https host header for for a web site named "MyWebSite" with a url "mywebsite.mydomain.com"
appcmd set site /site.name:"MyWebSite" /+bindings.[protocol='https',bindingInformation='*:443:mywebsite.mydomain.com']
Read Configure a Host Header for a Web Site for more details