As we just saw, it is pretty straightforward to configure multiple websites inside IIS by assigning individual IP addresses for each site. It is common to run more than one site on a single web server, and so this sometimes means that your web servers have numerous IP addresses configured on them. However, sometimes this is not possible. For example, you may be working on a web server that is Internet facing and there is a restriction on the amount of available public IP addresses that can be used. In this case, you may run across the need to host multiple websites on a single IP address, but you don't want to force the users into having to type in specific port numbers in order to gain access to the right website.
This is where host headers come into play. Host headers can be configured on your websites so that the site responds to a particular request coming in from the client. These header requests can help the web server distinguish between traffic, directing users calling for websites to their appropriate site inside IIS. Let's work together to set up two websites inside IIS and force them to utilize the same IP address and port. We want everything to remain standard as far as the port goes, so we want them to both be able to utilize port 80, but we only have one IP address available to install on our web server.
The work will be accomplished from inside IIS on our Server 2016 web server. We will also utilize a client computer to test connectivity to the websites once we are finished setting them up.
To create two websites that share the same IP address and split traffic by using host headers, follow these steps:
C:Websites
. Inside this folder, create two new folders and call them Site1
and Site2
.Default.htm
file. You should now have two different Default.htm
files, one sitting inside the Site1
folder, and one sitting inside the Site2
folder. These will be our example websites.Default.htm
files. Make sure that whatever text you write in them distinguishes between the websites so that we can know it is working properly when we test in a few minutes.Sites
folder, and choose Add Website….Site1
and choose our C:WebsitesSite1
folder as the location for this website. I am also going to drop down the IP address field and specify the one and only IP address on this system so that we can prove host headers are working as they should. Remember, our intention is to get two websites running on this same IP address and port combination.mysite1.mydomain.local
.
Site2
. We are going to choose the same IP address and Port, but we are going to specify a different name in the Host name field:
http://mysite1.mydomain.local
. You should see the text from the Default.htm
file that we put into the Site1
folder on the web server.
http://mysite2.mydomain.local
. We can see that the web server recognizes our request for the second site, and even though they are running on the same IP address, our request is sent over to the second website.
When we set up websites inside IIS to utilize different host headers, it gives us the ability to publish multiple sites on the same IP address and port numbers. This can be very useful in cases where IP addresses are limited or where you don't want to configure multiple addresses onto the web server for any reason. IIS is capable of listening on the same IP and port for web requests coming into different host names and forwarding those requests on to the appropriate website based on the host header name that was requested by the client computer. It is important to note that requests for these web pages must come by the name for this to work properly; you cannot type the IP address of the website into the browser and expect it to work, since we are now sharing that IP address between two or more different sites.
3.144.224.76