<

Go Premium for a chance to win a PS4. Enter to Win

x

Multiple websites on single instance of IIS

Published on
13,418 Points
7,118 Views
3 Endorsements
Last Modified:

Prologue

It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a possible implementation.

The benefits of multiple websites on single instance of web server are:

1.

Reduced hardware cost

2.

Reduced resource consumption

3.

Reduced maintenance

4.

Reduced physical space requirement
Alongside benefits there are limitations. Production servers usually have load balancers which roughly and by layman means same website on multiple servers. Therefore, a single server with multiple websites does have limitations in terms of the maximum possible load they can handle. There might be a resource problem if there is a heavy user base.

Not only IIS, other web servers like Apache also support hosting multiple websites on a single web server. Multiple websites hosted on a single web server need to differ in one of the three primary parameters while hosted:

1.

IP address

2.

Host header name

3.

Port number

Multiple websites using multiple IP addresses

When hosting two web sites (or more) on one web server we can associate the two web sites with two different IP addresses. Different configured web sites can be accessed with the configured IP addresses. For example,
Web site 1 - http://10.5.5.1 
Web site 2 - http://10.5.5.2 


Physically there is only one server machine which has two registered IP addresses but different IP addresses on the machine are mapped with different web sites.
Configuration

1.

Open the IIS Manager, which you can find in Administrative Tools or by typing its executable name (inetmgr.exe) into a command prompt or run window

2.

Right-click the web server name to open the context menuIIS context menu to add web site

3.

Select Add Web Site…

4.

Fill details on the popup which appears. Make sure you select a valid IP Address under binding section. Insert site name, default app pool, physical path and other values.Website two IP address

5.

Click Ok

6.

For second web site, follow steps #2 to #4. On step #4 enter different site name, physical path and IP Address. Set the IP Address 10.5.5.1 as per the example.
Adding multiple IP addresses to a machine is a hardware configuration which might differ by server hardware configuration. Ideally servers with multiple IP addresses have multiple NIC devices. In that case each NIC has a unique IP address. For example there are two NICs added to the server and one of which is configured to have IP 10.5.5.1 and the other to have 10.5.5.2
Alternatively, when there is only one NIC available to server then same NIC might be configured with two different IP addresses.

Both the cases are explained in the snapshot below where multiple NICs are shown with blue outline. From the Properties window the IP can be set to the NIC. The yellow marker represents the IP address configuration (IPv4) and the example is setting two different IP addresses to same NIC.
NIC Configuration and IP Addresses

Multiple websites using multiple host header name

When hosting two web sites (or more) on one web server we can associate the two web sites with two different host names. Different configured web sites can be accessed with different configured host names. For example,
Web site 1 - http://www.one.com 
Web site 2 - http://www.two.com 


Provided that the configured domain names are registered with same IP Address when accessible on Internet. For example,
Name = www.one.com, IP = 10.5.5.1
Name = www.two.com, IP = 10.5.5.1


If the server is accessible on Intranet then the server name and IP entry should be made in the domain name server (DNS server) of the local network.

To configure multiple web sites on a single server using the host header approach, all the steps will be same as above except step #4

When filling in the form to add a web site, multiple web sites will have different Host name configuration. For example:
Web site 1
Website one host header nameWeb site 2
Website two host header name

Multiple websites using multiple port numbers

When hosting two web sites (or more) on one web server we can associate the two web sites with two different port numbers on same IP address and host name. Different configured web sites can be accessed with different configured ports. For example,
Web site 1 - http://www.one.com:8080 
Web site 1 - http://www.one.com:8081


If the server is accessible on Intranet then the server name and IP entry should be made in the domain server of the local network.

To configure multiple web sites on single server       all the steps will be the same as those for multiple IP Addresses or multiple host header name, except step #4

When filling the form to add web site, multiple web sites will have different port number configuration. For example:
Web site 1 with port 8080
Website one port numberWeb site 2 with port 8081
Website two port number

Epilogue

These different approaches can be combined together and single server might host multiple websites using two different IP addresses (or may be more than that which is subjected to the hardware configuration) and multiple host header names along with the other approach of different port numbers.
The number of permutations/combinations might be tried till the server is capable of handling the load. Its not a real life scenario to have such a hosted server but worth a try on demo servers at least.
You can totally separate out different demo websites of different purposes which will help controlling the availability of website on random basis without stopping the web server.

Other possible use of the approaches might be during the maintenance of main website or upgrade of the website. You can keep one version of the website always running while you are running maintenance task on the other website. The server can also be load balanced a hardware as well as software.

To try this out on a standalone machine where neither multiple network cards nor the domain networks are available we would add MS loopback adapter in the network adapters and set multiple static IP Addresses in these added adapters and then modify the hosts file to map different URLs with different IP addresses.

On W7 machine, loopback adapter can be added using hdwwiz.exe and selecting Microsoft Loopback Adapter from the list of adapters.

The hosts file can be found at c:\Windows\System32\drivers\etc. Due to the security introduced by User Account Control (UAC) the text editor might need opened in elevated access mode (runas admin) to edit hosts file.
3
Comment
Author:Neeraj Soni
  • 2
4 Comments
 
LVL 6

Author Comment

by:Neeraj Soni
Thank you.

Neeraj
0
 
LVL 58

Expert Comment

by:tigermatt
An excellent idea for an article. +1

- Matt
0
 
LVL 6

Author Comment

by:Neeraj Soni
Thank you, Matt.

- Neeraj
0
 

Expert Comment

by:anbu210
Really Good Info....
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Join & Write a Comment

Loops Section Overview
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month