简体   繁体   中英

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

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.

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"

see below how I used to SSL port 443

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

Where it is in bold, change the information

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM