如何在具有相同端口但具有不同主机头的IIS服务器中托管多个站点并公开访问它 [英] How to host multiple site in IIS server with same port but with different host header and accessing it publicly

查看:51
本文介绍了如何在具有相同端口但具有不同主机头的IIS服务器中托管多个站点并公开访问它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在IIS服务器中托管多个网站.我可以使用其他端口托管它.但是我不想为不同的网站使用不同的端口.我也尝试使用主机头,但是我只能在本地访问这些头.我想公开/外部访问这些标头.我怎样才能做到这一点?我还配置了DNS.但是我无法公开访问它.可以将一个网站的www.test.com和另一个网站的www.test.com/site2赋予吗?

I am trying to host multiple web sites in IIS server. I am able to host it with different ports. But i don't want to use different ports for different website.I also tried using host header but i am only able to access those headers locally. I want to access those header publicly/externally . How can i do that? I have also configured DNS.But i am not able to access it publicly. Will it be possible to give www.test.com for one site and www.test.com/site2 to another site?

推荐答案

IIS服务器可以托管多个网站,但是为了使IIS正确分发HTTP请求,必须使用每个唯一的值来标识每个网站.对于IIS网站,它由三个属性组成,这三个属性构成每个网站的唯一组合.

IIS server can host multiple websites, but in order IIS to distribute HTTP requests correctly, each website has to be identified with some unique value. In case of an IIS website, it consists of three attributes that make up a unique combination for each website.

这些是:

  • TCP端口号
  • IP地址
  • 主机头

如果要在同一端口和IP地址上托管多个网站,则必须使用唯一的Host标头.

If you want to host multiple websites on the same port and IP address, you will have to use a unique Host header.

主机头是客户端发送到服务器的HTTP请求的一部分,该请求指定了将其定向到的网站.因此,必须在Web服务器端指定此主机头,并且DNS包含与Web服务器的主机名和IP地址匹配的正确条目.

The host header is a part of an HTTP request to the server sent by a client that specifies which website it is addressed to. Accordingly, this host header must be specified on the side of the web server, and the DNS contains the correct entry that matches the hostname and the ip address of the webserver.

您不能设置主机头,如www.test.com/site2.如果要使用此格式,则可以将site2作为子应用程序托管在www.test.com主机头所包含的网站下.

You can not set the host header like www.test.com/site2. if you want to use this format you can host the site2 as sub-application under the www.test.com host header contained site.

要创建唯一绑定,请为第二个网站指定另一个名称(主机名).右键单击TestSite,然后选择编辑绑定".选择所需的绑定,然后单击编辑".在主机名"字段中,指定用户要寻址的唯一主机名,例如TestSite.

To create a unique binding, specify another name (Host Name) for the second website. Right-click TestSite and select Edit Bindings. Select the binding you need and click Edit. Specify the unique hostname the users will address to, like TestSite, in the Host Name field.

现在,您需要为DNS添加服务器的别名(A或CNAME),以指定IP地址或Web服务器的名称.

Now you need to add an alias for the server (A or CNAME) to DNS that specifies the IP address or the name of your web server.

您可以在DNS控制台(dnsmgmt.msc)中为名称TestSite创建一个CNAME条目,并将IIS服务器的域名指定为FQDN目标主机.

You can create a CNAME entry for the name TestSite in the DNS console (dnsmgmt.msc) and specify the domain name of your IIS server as FQDN target host.

使用PowerShell:

using PowerShell:

Add-DnsServerResourceRecordCName -HostNameAlias web-srv1.contoso.loc -Name testsite -ZoneName contoso.loc

如果要访问本地IIS服务器,则通过文件C:\ Windows \ system32 \ drivers \ etc \ hosts完成站点名称到服务器IP地址的映射.

If you want to access a local IIS server, the mapping of site names to the server’s IP address is done via the file C:\Windows\system32\drivers\etc\hosts.

当您要公开访问该站点时,需要购买域名和公共IP地址.如果您不从公共域名提供商处购买域名,那么互联网客户端将无法解析您的域名.

when you want to access the site publically you need to buy the domain name and public IP address. If you don't purchase the domain from a public domain provider, then your domain name can't be resolved by an internet client.

这篇关于如何在具有相同端口但具有不同主机头的IIS服务器中托管多个站点并公开访问它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆