How to set hostname during SSL binding in IIS7

Recently I have talked to few customers who were looking for a way to add hostname on SSL binding. They were using IIS7 and unable to use the IIS Manager UI for it. In fact, IIS Manager "Add Site Binding" UI had the "Host name" field greyed out! Here is how to resolve it.

Note: You can set hostname using IIS7 manager while your binding type is "HTTP", but not when your binding type is "HTTPS".

The Solution: You need to use appcmd.exe that you can find under c:\windows\System32\inetsrv

appcmd set site /site.name: string  /+bindings.[protocol=' string ',bindingInformation=' string ']

The variable site.name string is name of the site to which you want to add a binding. The variable protocol string is the protocol that you want to use, and the variable bindingInformation string is the combination of IP address, port, and host header.

For example, to configure a site named contoso to have an HTTPS binding for all IP addresses, on port 443, without a host header, type the following at the command prompt, and then press ENTER:

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

Comments

  • Anonymous
    October 22, 2014
    Just found IIS UI allows to specify hostname if https binding uses wildcard certificate.

  • Anonymous
    November 18, 2014
    This does not work.  If I create the initial binding, this command creates a second binding with the host name.  I have to remove the binding without the hostname as per government STIG requirements.  Doing this then disassociates the certificate with the binding, thus rendering the binding useless.