How to use appcmd.exe to add a new binding for HTTPS

18.6k views Asked by At

I have the following script that sets up my website...

%AppCmd% ADD SITE /name:%SiteName% /physicalPath:%SitePath% /bindings:http/*:80:%SiteName%
%AppCmd% SET SITE /site.name:%SiteName% /[path='/'].applicationPool:%SiteName%

What I would like to do now is to find out how to add an additional binding for HTTPS. Seen plenty of pages describing now to add a host header to an existing https binding but none that show actually how to add a new binding as you can do in the UI.

Note: I believe I need two bindings, one HTTP (port 80) and one HTTPS (port 443) as at present I need to have port 80 open as I use a redirect rule to swap people that hit the site on port 80 over onto 443. If there is a way I can avoid doing this and simply my bindings I'm all for it.

2

There are 2 answers

0
César Augusto On

see below how I used to SSL port 443

appcmd set site /site.name:NAME_SITE_IIS /+bindings. [protocol='https',bindingInformation=':443:yourdomain.com.br']

Where it is in bold, change the information

0
Ercan On

You can add multiple bindings for http or https.

Open command line and set path

cd %windir%\system32\inetsrv

add first binding

appcmd set site "mysite.domain.com.tr" /bindings:"https://mysite.domain.com.tr:443"

add other bindings

appcmd set site /site.name:mysite.domain.com.tr /+bindings.[protocol='https',bindingInformation='*:443:mysite1.domain.com.tr']
appcmd set site /site.name:mysite.domain.com.tr /+bindings.[protocol='https',bindingInformation='*:443:mysite1.domain.com.tr']
appcmd set site /site.name:mysite.domain.com.tr /+bindings.[protocol='https',bindingInformation='*:443:mysite1.domain.com.tr']

And you can export web site config file as xml

%windir%\system32\inetsrv\appcmd list site "mysite.domain.com.tr" /config /xml > "C:\Users\Administrator\Desktop\backup\mysite.domain.com.tr.xml"