简体   繁体   English

如何使用appcmd.exe为HTTPS添加新的绑定

[英]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. 我现在想做的是找出如何为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. 看到了很多页面,这些页面现在描述了如何将主机标头添加到现有的https绑定中,但是却没有一个页面能够像在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. 注意:我相信我需要两个绑定,一个HTTP(端口80)和一个HTTPS(端口443),因为目前我需要打开端口80,因为我使用重定向规则将在端口80上访问网站的人交换到443.如果有一种方法可以避免这样做,而只是绑定就可以了。

You can add multiple bindings for http or https. 您可以为http或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 您可以将网站配置文件导出为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 参见下面我如何使用SSL端口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 '] appcmd set site /site.name:NAME_SITE_IIS /+bindings. [protocol='https',bindingInformation=' :443:yourdomain.com.br ']

Where it is in bold, change the information 粗体字处更改信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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