Configuring SSL Host Headers

Host headers in IIS are a way to associate multiple names with a single address. The typical use of host headers is to be able to host more than one web site at a single IP address by giving each of the web sites a distinct DNS name. Host headers also play a role in WCF beyond the definition of a web site. Metadata for a web service, such as that appearing WSDL, uses host headers as a way to pick a preferred name when talking about the service.

The user interface for setting host headers is relatively straightforward when the web site is hosted over HTTP but becomes a challenge when the web site is hosted over HTTPS. Here are the command line equivalents that you can use to set HTTPS host headers.

On IIS 6, you need to know the id of the web site. Assuming that SSL is taking place on the default port, the command looks like this.

cscript.exe adsutil.vbs set w3svc/<id>/SecureBindings ":443:<header>"

On IIS 7, the command line looks very different due to the more flexible but complicated support for different web site bindings. You can also use a name that's meaningful for you to distinguish web sites.

appcmd set site /site.name:<name> /+bindings.[protocol='https',bindingInformation='*:443:<header>']

To keep the example simple, I'm assuming that you're adding a new binding rather than modifying an existing binding.

Next time: Transaction Header Magic