Windows Server 2016 – Hosting multiple websites on your IIS server

How to Install MySQL 8.0 on Ubuntu 18.04

Spinning up a web server, implementing the IIS role, and hosting a website are great first steps. Depending on the size and importance of your website, you may even require multiple web servers running that will serve up exact copies of the same website and have load balancing configured between the multiple web servers. On the other hand, it is probably more likely that your website will actually be an underutilization of your server’s resources, rather than an overutilization, and so you have now created a new web server hosting a single website, and it’s really not being taxed at all. Is there a way that we can make use of that extra hardware that is currently sitting idle? Perhaps you have additional websites or web services that need to be turned on, for which you were planning to spin up multiple servers. The good news is that IIS is capable of hosting many different websites at the same time. We can take that underutilized server and create additional website listeners on it so that you can serve up multiple web pages from the same physical server.

There are a couple of different ways that we can host multiple websites on the same IIS server at the same time, through the use of multiple ports or multiple IP addresses. Let’s take a minute and test both avenues.

Getting ready

We are going to use IIS on our WEB1 server today in order to host multiple websites. We will also need access to DNS in order to create names for these websites.

How to do it…

Follow these steps to host multiple websites on the same IIS server:

  1. First, we need to create some sites that will be served up by IIS. Inside my c:\inetpub folder, I am simply creating four new folders. Inside each folder will be a simple Default.htm file that contains some text. This way I can serve up these different web pages on different sites inside IIS, and later browse to them individually to prove that IIS is serving up all of the different web pages:
  2. Now open up Internet Information Services (IIS) Manager and browse to the Sites folder. Right-click on Sites and choose Add Website… four different times to walk through the process of creating your four new websites. For each site, make sure to choose the appropriate folder on the hard drive for serving up the correct page.
  1. At this point in time, we only have one IP address on our web server. So in order to allow IIS to host multiple websites on this single IP address, we are going to take the approach of having each website run on its own port number. When you configure the Add Website screen, identify a unique port number under the Binding session for each site. This will permit all four websites to run at the same time using the same IP address, because each site will be running on a unique port number:
  2. Now you can see that all four of our websites are started, and each is running on its own port number:
  1. Client computers in the network can now browse the following links and successfully see the four different web pages being served up by our IIS server:
    • http://web1:81
    • http://web1:82
    • http://web1:83
    • http://web1:84
  2. Requiring the users to type in a specific port number when they want to access websites isn’t something they are going to appreciate, so let’s try hosting these four different websites on our WEB1 server in a different fashion. Instead of using different port numbers, we are now going to take the approach of hosting each website on its own unique IP address. In order to start that process, open up the NIC properties of the WEB1 server and plug in three additional IP addresses that we can use specifically for hosting these websites:
  3. Now back inside IIS, right-click on each of your websites and modify Bindings… so that each website is once again using the default port 80, but it is also running on its own unique IP address:
  1. Once the four websites are each running on their own IP addresses, you can create DNS host records so that each site has a unique DNS name on the network as well. Simply point these four new DNS names to the corresponding IP address where the site is running, and your client computers can now access the websites via individual hostnames on the network:
    • http://site1.mydomain.local
    • http://site2.mydomain.local
    • http://site3.mydomain.local
    • http://site4.mydomain.local

How it works…

Whether you decide to host multiple websites on a single web server by splitting up access at the port level or the IP address level, it is important to know that you can push the limits of your web server a little bit by hosting multiple things at the same time. IIS is more than capable of handling this division of resources, and as long as your hardware is keeping up with the task, you can continue to grow vertically in this way and save the number of servers you have running, rather than having to grow out horizontally by installing server after server after server, as you begin to need additional web resources.

Comments are closed.