Y B
Y B

Reputation: 125

How to host multiple site in IIS server with same port but with different host header and accessing it publicly

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?

Upvotes: 7

Views: 32773

Answers (1)

Jalpa Panchal
Jalpa Panchal

Reputation: 12749

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.

These are:

  • TCP port number
  • IP address
  • Host header

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

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.

You cannot 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.

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.

enter image description here

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.

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.

enter image description here

using PowerShell:

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

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.

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.

Upvotes: 6

Related Questions