Self-Hosting Multiple Websites in IIS

Did you know that you could host a website on a computer with Windows installed? Did you know you can host 2 websites? Or even 3? Well, you absolutely could do this!

In this blog post, I want to document useful information about using the Microsoft IIS feature or Internet Information Services.

What is IIS?

IIS is Microsoft’s web server product. It is a feature of Windows client operating systems and Windows Server.

Why should you care about IIS?

If you are ever curious about hosting a web server and are intimidated by Linux, I think that IIS is a good place to start. If you already have Windows 10 or 11 you can locally host some websites on your computer.

Also if you understand how to use IIS, it could be useful to know when you are building out a Windows domain. The next time you spin up a Windows domain controller, or other Windows virtual machines, consider adding a web server to your lab. It could be fun!

How do you install IIS on Windows 10 / 11?

Open up Control Panel and then open “Programs and Features.” Then select “Turn Windows features on or off.”

word image 25706 1 1

Find “Internet Information Services” and select the features that are checked off in the below screenshot. It is important to install the Application development features because this will allow you to load sites that have .aspx files.

word image 25706 2 1

After you select ok, IIS should install and you should be able to search for it on your computer.

word image 25706 3 1

Creating your first website

And just like that, you have just set up a web server on your Windows computer! Upon opening IIS Manager for the first time you will notice there is a default website. You can load the website in a web browser just by typing “localhost” in the address bar:

word image 25706 4 1

I deleted this and created a new website. To create a new website, open IIS Manager, and click “Sites.” And then select “Add Website.”

word image 25706 5 1

Give your website a name:

word image 25706 6 1

Next you must create a folder to put all the files for your new website. You can put the website files anywhere you want. I will be putting the files in this file path:

C:\inetpub\anothersite

word image 25706 7 1

Next, you need to specify the binding. What this does is bind a port number to the website. This becomes important if you are hosting multiple websites on the same server.

word image 25706 8

If there is a single IP address assigned to a web server and there are multiple websites hosted on that server, this can pose a problem. How will the server know which website to return to the client machine?

This is where bindings come in. A port number is bound to the website’s hostname. If there are multiple websites, each website should be bound to a different port number. Since this website will be hosted locally on my machine for testing purposes, I will set the value for the IP Address to “All Unassigned.”

word image 25706 9 1

Downloading Sample Websites

If you are reading this and you are a web developer or have some solid experience creating websites, by all means, upload your website’s files to the folder you created earlier. For this lab, I will be downloading a sample website that is freely available on free-css.com.

Configuring The Host File

After uploading your website’s files to the correct folder on your computer, you need to configure the host file. Open up Notepad and run it as administrator. Next, navigate to C:\Windows\System32\drivers\etc and open the “hosts” file. At the bottom of the file add the loopback address of 127.0.0.1 followed by the hostname of your website.

word image 25706 10 1

Check out your website!

Open a browser and type the hostname of your website into the address bar:

word image 25706 11 1

Installing IIS on Windows Server 2022

The following considerations are for installing and setting up IIS in a Windows domain using Windows Server 2022. I have created two Windows Server 2022 virtual machines in Azure in this lab environment. I have installed the AD DS role on one server and IIS on the other.

To install the IIS role on Windows Server 2022, open Server Manager and then select Manage>Add Roles & Features:

word image 25706 12 1

Select Next:

word image 25706 13 1

Select Next on this screen as well:

word image 25706 14 1

Select the server you would like to install IIS and select Next:

word image 25706 15 1

Select the checkbox next to the Web Server (IIS) role:

word image 25706 16 1

Select Add Features:

word image 25706 17 1

Select Next:

word image 25706 18 1

Select Next on the next two screens:

word image 25706 19 1
word image 25706 20 1

On the Role Services screen, make sure you select the features highlighted in the below screenshot. The defaults that are chosen are generally ok. Feel free to install any additional features you see fit. The reason why I selected these application development features is so I can use websites that have .aspx files.

word image 25706 21 1

Select Install on this screen

word image 25706 22 1

Launch IIS from Server Manager!

word image 25706 23 1
word image 25706 24 1

Creating An A Record For Your Website

If you are just using a standalone Windows Server 2022 instance you can follow the steps mentioned earlier and edit the hosts file so that you can resolve multiple websites. If your IIS server is joined to a Windows domain, you need to create an A record on the DNS server so that you can resolve additional websites you might host.

Open DNS Manager and create a new Forward Lookup Zone:

word image 25706 25 1

Select Next:

word image 25706 26 1

The defaults for the next three screens are usually fine unless you have specific needs for your DNS server.

word image 25706 27 1
word image 25706 28 1
word image 25706 29 1

Give the new Forward Lookup Zone a name. You want to give it the same name as the hostname of your website:

word image 25706 30 1

Select Finish:

word image 25706 31 1

Next you want to create a new A record in the forward lookup zone you just created. Make sure it is selected in the navigation pane on the left, right mouse click anywhere on the right and select New Host A:

word image 25706 32 1

You can leave the name blank here unless you want to give your website an additional name that can be used to resolve the website. For example you can give this record the name of “www” so that you can resolve your website by entering www.website1.com. Keep in mind you would need to change the hostname in IIS.

Enter the IP address of your Web Server. This IP address really should be a static IP address. Only select ‘Create Associated PTR record” if you have a reverse lookup zone configured for your subnet. In my case I do so I will select this and then click add host.

word image 25706 33 1

Select ok

word image 25706 34 1

Open a web browser and open your website!

word image 25706 35

Scroll to Top