loading...

Microsoft IIS 10.0 – Hosting multiple websites

How to build a Docker Compose YAML files

In this recipe, we will create three websites in IIS 10.0: mysite.com, v2mysite.com, and v4mysite.com. We will make the hostname entries in the hosts file later in this chapter. We will access the website with its hostname.

Let’s move on to the next section, where we will be covering this in detail.

Getting ready

To step through this recipe, you will need a running IIS 10 instance and administrator user account. You are going to create and configure the website’s properties.

How to do it…

  1. Open Server Manager in Windows Server 2016. Click on the Tools menu and open IIS Manager.
  2. Expand the IIS server from the Connections panel. We get the listed Application Pools and Sites folder.
  3. Expand the Sites menu in the left-hand side panel under the computer name and click on Default Web Site. You can find it using this figure:
  1. Go to the Actions panel at the top-right and click on Bindings under Edit Site. You will get the default S ite Bindings option:
  1. Here, you can see the only default information available, which has Type as http, Port number 80, and IP address * (asterisk), which means one IP address will be assigned automatically for each site. One server can have multiple IP addresses; for example, one IP is used for shared hosting, and we can also set up a different dedicated IP for individual sites for better bandwidth and performance.
  2. Click on the Edit button, and you will get the Edit Site Binding option, as highlighted in this figure:
  1. You know that we have selected the Default Web Site binding property. Hence, we are configuring the Default Web Site to be accessed through the hostname or IP.
  2. Enter the IP address; we are going to enter IP address 172.16.15.60. This IP address used in our demo case, but in your case it can be different. Before you start typing the IP address, make sure that it is your IP address, but you can keep the same example domain name. Enter the new hostname or domain name. We entered the host name v2mysite.com.
  3. Leave the default Port 80. Click on OK.

 

 

  1. Go to the Site menu of IIS Server Manager, which is available in the left side panel and select the Default Web Site. Rename it as v2mysite.com by either right-clicking on the get context pop-up menu to select Rename or under the Actions pane by clicking on Basic Settings to get the same option to rename it. Renaming the website is only for identifying the website.
  1. Now we are going to add v4mysite.com. Inside the Connections pane, click on the S ites menu, go to the Actions panel, and click on Add Websites…. You will get the Add Websites… window:
  2. We add the Site name v4mysite.com and select the A pplication pool 2and3.5AppPool.
  3. Leave the default directory as wwwroot. We add the IP address same as the server IP.
  1. Leave the port number as the default port number, which is 80. The hostname is v4mysite.com. Start Website immediately is the default option, checked. Click on the OK button.
  2. We will follow the same steps for adding more websites; we will create one more website with the name mysite.com.
  3. Now we have three websites created with three different names with the same IP address:
  1. Let’s move to configure a few more steps to access these websites through the domain name.
  2. Go to the C:\ drive, open the Windows folder, and search for System32. Inside the System32 folder, open the drivers folder.
  1. There is an etc folder inside the drivers folder:
  1. Open the hosts file in Notepad. Make sure that Notepad opens with administrator privileges by right-clicking on the Notepad icon and clicking on Run as Administrator; it will only allow you to save the changes. Now we have to make the web site hostname entry:
  1. As shown in the previous figure, we made three website entries, which are mysite.com, v2mysite.com, v4mysite.com. All the site IPs are the same, 172.16.15.60. In your case, the IP address should be different.
  2. Save the hosts file and close it. Now you are done with all the configurations for multiple website hosting.

How it works…

Multiple website hosting on the same IIS 10 server helps us easily manage all the website-related tasks on the same server. We have just created three websites on the same IIS server. You can create many websites as per your requirements.

A hosts file entry is required when you want to get access to the website with the domain name, for example, mysite.com. You can also use the DNS server to access this website through LAN or WAN.

Comments are closed.

loading...