Windows OS Hub
  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows Server 2022
    • Windows 10
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
  • PowerShell
  • Linux

 Windows OS Hub / Windows Server 2019 / Hosting Multiple Websites in IIS with Same Port and IP Address

January 29, 2024 Windows 10Windows Server 2019Windows Server 2022

Hosting Multiple Websites in IIS with Same Port and IP Address

When you install an IIS (Internet Information Services) web server on Windows, an empty “Default Web Site” is created, listening on the default HTTP port 80. In this article, we will find out how to host multiple websites on an IIS web server and bind them to the same HTTP or HTTPS port and one or more IP addresses.

Contents:
  • Running Multiple Websites on IIS Server using Host Headers
  • Run Multiple Websites with Different IP Addresses on IIS
  • Managing IIS Web Site Bindings with PowerShell

Run https web site on IIS on Windows

Running Multiple Websites on IIS Server using Host Headers

Assuming you’ve already created an HTTPS website on IIS running on port TCP:443 (How to install SSL certificate on IIS).

Create a second site in the IIS management console (inetmgr). Click Site -> Add website. Specify the name of the site (TestSite) and the path to the site files directory (c:\inetpub\TestSite). Specify HTTPS type, port 443, select an SSL certificate in the Bindings section. Don’t specify a hostname yet.

Adding second website on IIS web server

When you try to start a new website, you get an error saying that one port (443) is used by multiple sites. Only one IIS site can run on this port at a time.

This website cannot be started. Another website may be using the same port.

This website cannot be started. Another website may be using the same port.

For the IIS web server to correctly distribute HTTP requests across multiple sites, each site must have a unique identifier. In IIS, such an identifier is defined by three attributes:

  • TCP port number
  • IP address
  • Host name (host header)

The value of these attributes for each site is stored in the ServerBindings attribute of the IIS metabase in the following format: IP:Port:Hostname. If the values of all three attributes are the same for two sites, IIS won’t be able to start the second site. To run a second site on the same port and IP address, you need to give it a unique name (host header) and create a DNS record that matches the name of the site to its IP address.

So, to run a second site, you need to go to Edit Bindings -> Edit and add a unique DNS name for this site to the Host header. For example, testsite.contoso.com.

change iis website host name (binding)

If HTTPS sites use different SSL certificates and they are running on the same IP address, you must enable the Server Name Indication (SNI) option in the Binding section for such sites. If this is not done, IIS cannot determine which certificate to use (because the HTTP site headers are not yet available during the SSL/TLS handshake).

Enable Server Name Indication (SNI) opiton in IIS

IIS website binding settings are stored in the IIS configuration file (C:\Windows\System32\inetsrv\config\applicationHost.config)  in the <sites> section.

You can also configure IIS site binding from the command prompt:

C:\Windows\System32\inetsrv\appcmd.exe Appcmd.exe set site "testsite" /bindings:"https://testsite.contoso.com:443"

You can now start the second site.

Running multiple websites on IIS

Add a DNS entry for the name of your new website. This can be an A or CNAME record pointing to the IP address or hostname of the IIS web server.

If you are deploying a web server in an Active Directory domain zone, create a DNS record on the domain controller. You can use the DNS console (dnsmgmt.msc) to create a CNAME record. Specify the name of your host running IIS as the FQDN target host.

Create DNS record for IIS website

It is also possible to use PowerShell to create a DNS record:

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

You can now open your second website https://testsite.contoso.com in a browser.

hosting multiple websites on the same IIS port 443

You can use the URL Rewrite module to enable the redirection of the IIS web address from HTTP to HTTPS.

If you are using a standalone IIS server, you can map website names to the IP address of the server using the hosts file (C:\Windows\system32\drivers\etc\hosts).

Run Multiple Websites with Different IP Addresses on IIS

The IIS web server also allows you to host sites on different IP addresses. First, add an additional IP address to Windows. This can be done by adding a separate VLAN interface or by assigning an additional IP address (alias) to the network interface.

In this example, the IP address of the Windows Server host is 192.168.13.100. Let’s add an additional IP address 192.168.13.101 to the same network adaptor:

Get-NetIPAddress | ft IPAddress, InterfaceAlias, SkipAsSource
New-NetIPAddress –IPAddress 192.168.13.101 –PrefixLength 24 –InterfaceAlias “Ethernet” –SkipAsSource $True

add additional ip (alias) on windows

Now you need to create an A record for the new site on the DNS server We will also create a PTR record in the reverse lookup zone by adding the –CreatePtr option):

Add-DnsServerResourceRecordA -Name NewSite3 -IPv4Address 192.168.13.101 -ZoneName contoso.com -TimeToLive 01:00:00 –CreatePtr

Then bind the site to the new IP address in the Site Binding configuration.

Change IP address in IIS web server binding

Managing IIS Web Site Bindings with PowerShell

You can manage website binding on the IIS server using the built-in PowerShell WebAdministration module:

Import-Module WebAdministration

View information about all available IIS sites and their bindings:

Get-IISSite

powershell: list iis website bindings

Or about a particular website:

(Get-Website -Name testsite).bindings.Collection

Change the TCP port of the website from 443 to 81:

Set-WebBinding -Name testsite -BindingInformation "*:443:testsite.contoso.com" -PropertyName 'Port' -Value '81'

Change the IP address of the website:

Set-WebBinding -Name testsite -BindingInformation "192.168.13.101:81:testsite.contoso.com" -PropertyName 'IPAddress' -Value '192.168.13.100'

Add a new IIS site binding:

New-IISSiteBinding -Name testsite -BindingInformation "*:8080:" -Protocol http

Remove website binding:

Remove-IISSiteBinding -Name NewSite3 -BindingInformation "*:9090:"

This allows you to run multiple sites on the IIS web server, both on different IP addresses and on the same IP address and/or TCP port.

4 comments
5
Facebook Twitter Google + Pinterest
previous post
UAC: This App Has Been Blocked for Your Protection on Windows 10
next post
How to Create and Manage Scheduled Tasks with PowerShell

Related Reading

Configure NTP Time Source for Active Directory Domain

May 6, 2025

How to Cancel Windows Update Pending Restart Loop

May 6, 2025

View Windows Update History with PowerShell (CMD)

April 30, 2025

Cannot Install Network Adapter Drivers on Windows Server

April 29, 2025

Change BIOS from Legacy to UEFI without Reinstalling...

April 21, 2025

4 comments

راه اندازی چند ساب دامین با یک Ip November 6, 2018 - 6:53 am

[…] کنید و مطالعه : Run Multiple Websites on the Same Port and IP Address on IIS | Windows OS Hub Mohammad Rasoul Rasti There's no place like 127.0.0.1 m.rasti [@] outlook.com […]

Reply
Andrea Ramacciotti February 4, 2020 - 11:15 am

I did as you suggested for an application that require Windows Authentication. The one that reply when the host name is “localhost”, works fine, whilst the second one that reply on a different host name (the one that I defined in file hosts as 127.0.0.1) request the authentication three tiimes and then fails with 401 code.
Any suggestion?

Reply
admin February 11, 2020 - 7:41 am

Try to create an A record in your DNS instead of a line in the hosts file.

Reply
Mark December 26, 2020 - 5:39 am

Very good article but I don’t have any servers in Server Manager under Windows 10. I believe that’s expected but how to add a DNS server there? Can

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMware
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Cannot Install Network Adapter Drivers on Windows Server

    April 29, 2025
  • Change BIOS from Legacy to UEFI without Reinstalling Windows

    April 21, 2025
  • How to Prefer IPv4 over IPv6 in Windows Networks

    April 9, 2025
  • Load Drivers from WinPE or Recovery CMD

    March 26, 2025
  • How to Block Common (Weak) Passwords in Active Directory

    March 25, 2025
  • Fix: The referenced assembly could not be found error (0x80073701) on Windows

    March 17, 2025
  • Exclude a Specific User or Computer from Group Policy

    March 12, 2025
  • AD Domain Join: Computer Account Re-use Blocked

    March 11, 2025
  • How to Write Logs to the Windows Event Viewer from PowerShell/CMD

    March 3, 2025
  • How to Hide (Block) a Specific Windows Update

    February 25, 2025

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Repair EFI/GPT Bootloader on Windows 10 or 11
  • How to Restore Deleted EFI System Partition in Windows
  • Network Computers are not Showing Up in Windows 10/11
  • Install and Manage Windows Updates with PowerShell (PSWindowsUpdate)
  • How to Download Offline Installer (APPX/MSIX) for Microsoft Store App
  • Updating List of Trusted Root Certificates in Windows
  • Fix: Windows Cannot Connect to a Shared Printer
Footer Logo

@2014 - 2024 - Windows OS Hub. All about operating systems for sysadmins


Back To Top