Solved

How do I host two websites on one IIS server.

Posted on 2014-04-22
16
252 Views
Last Modified: 2014-05-01
I have hosted IIS 7 on Windows 2008 R2, the server has public IP 180.x.x.x. I also own two domain names.

I would like to host two different websites on this server. What I would like to know is,

1. Do I need two public IP's for hosting two different websites?
2. How do I map two domains to two different virtual directories on same server.

The objective is to run two websites from the same server.
0
Comment
Question by:sandeepjadhav
  • 6
  • 6
  • 4
16 Comments
 
LVL 29

Expert Comment

by:becraig
ID: 40016854
Simply use host headers

You can bind both sites to the same ip address
Here is how

http://technet.microsoft.com/en-us/library/cc753195(v=ws.10).aspx
0
 
LVL 37

Expert Comment

by:bbao
ID: 40016889
you can do that and you don't need one more IP for doing that.

as it is a standard feature of IIS, M$ has an official KB guide you do that in steps.

How To Use Host Header Names to Configure Multiple Web Sites
http://support.microsoft.com/kb/308163
0
 
LVL 37

Accepted Solution

by:
bbao earned 100 total points
ID: 40016893
you can do that and you don't need one more IP for doing that.

as it is a standard feature of IIS, M$ has an official KB guide you do that in steps.

How To Use Host Header Names to Configure Multiple Web Sites
http://support.microsoft.com/kb/308163
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:sandeepjadhav
ID: 40016947
Ok, after I configure sites using host header, I will need to make DNS entries for "A" record for these sites. Do I use same public IP for the "A" records of the both the sites. Will that it work ?
0
 
LVL 37

Expert Comment

by:bbao
ID: 40016954
YES. that's it, very simple.

the two sites will be resolved to the same IP address, hence the incoming web traffic will go to the same IIS server, and the server will determine the traffic for two virtual sites depending on its host header.
0
 
LVL 29

Expert Comment

by:becraig
ID: 40017955
Also one additional question, do you intend to use ssl on either or both of these sites  ?

If you do here is a step by step for binding multiple sites to SSL using the same ip and port


http://blogs.msdn.com/b/varunm/archive/2013/06/18/bind-multiple-sites-on-same-ip-address-and-port-in-ssl.aspx
0
 

Author Comment

by:sandeepjadhav
ID: 40024428
Ok, here is what is happening now.
I have two sites configured. Let’s say WS1 and WS2.
WS1 is a default site and WS2 is another site configured.  
1.      When I put host header entry in WS1 and browse from local machine, it tries to look for  the site on internet and goes to some random webpage in the internet.
2.      It then becomes inaccessible from by IP address as well, however if I remove the website name from the bindings. It is accessible by the IP address.
3.      If I stop WS1, WS2 becomes inaccessible.
4.      When I do binding for WS2, I cannot browse it from the local machine and it gives error site not found (I wonder why it does not go to some random webpage like in case of WS1).
4. I can browse WS2 using IPaddress/virtualdirectory but only if binding entries is removed
5.      If I do DNS entry for WS2, shows the index page of WS1

What could be happening here.

Thanks in advance.
0
 
LVL 37

Expert Comment

by:bbao
ID: 40024454
> 1. ... from local machine, it tries to look for  the site on internet

the DNS sever used by this IIS server cannot recognise the host name. is the IIS using your internal DNS server?

> 2. It then becomes inaccessible from by IP address as well

that's by design, as the IIS can't determine which site you are going to access.

> 3. If I stop WS1, WS2 becomes inaccessible.

how do you stop a site? wondering if you actually stopped the IIS engine (the services).

> 4. When I do binding for WS2, I cannot browse it from the local machine

is it OK to access from the internet? if so, as explained above, the DNS settings of the local IIS causes it.

> why it does not go to some random webpage like in case of WS1.

it depends on the browser's setting on how to 'guess' unknown site.

> 5. I can browse WS2 ... only if binding entries is removed

by design, as explanied above.

> 6. If I do DNS entry for WS2, shows
the index page of WS1

how did you set up the DNS entry for WS2?
0
 

Author Comment

by:sandeepjadhav
ID: 40024596
Is the IIS using your internal DNS server?
Response
The DNS server is that of my service provider. I am updating  A record with the public IP of my server at the service provider for the domains in questions.

How do you stop a site? wondering if you actually stopped the IIS engine (the services).
Response
I stop the website, and not the IIS engine from “Manage Website” options under in Actions Pane

Why it does not go to some random webpage like in case of WS1.It depends on the browser's setting on how to 'guess' unknown site.
Response
WS1 and WS2 should show identical behaviour of either pull a random website or show page not found, as the Server and browsers are same in both the cases. But that may not be important point hers.

How did you set up the DNS entry for WS2?
Response
I put same public IP address against A record of WS1 and WS2 at my domain registrar.
0
 
LVL 29

Expert Comment

by:becraig
ID: 40024751
Ok so back to where I started:
1) you must use host headers so IIS knows that site it is processing a request for.
Since you indicate when you do, your browser ends up doing a random search, then you do not have a dns record that matches the site you are trying to reach.

If this is a resolvable .com .org etc name that has been registered, simply have your host point you to a name server where you can have your ip registered  for the A record for the website.

If this is not a publicly resolvable name then you need to :
a. Use internal DNS
b. Use host files for resolution.

If you want to verify if your domain is properly registered and the DNS is resolving correctly.

windows key + r
cmd "hit enter"
nslookup "hit enter"
set q=a "hit enter"
www.yourdomain.com "hit enter"

The results you get should match your IP, if not then you are not registered and we should use either internal dns or a host file to allow you to test until the public dns is sorted out.
0
 

Author Comment

by:sandeepjadhav
ID: 40025513
windows key + r
cmd "hit enter"
nslookup "hit enter"
set q=a "hit enter"
www.yourdomain.com "hit enter"
The results you get should match your IP

Response
It matches the IP address of the domain, so the DNS issue is ruled out.

 Actually, I have two domains registered, let’s call them www.d1.com and www.d2.com  when I put my public IP in DNS against www.d2.com , it lands on the directory meant for www.d1.com.

If I update “A” record of www.d2.com  with the IP address of other website on different server it works perfectly.

One more point I want to highlight, all this while www.d1.com was running fine however it was without host header binding. If I put host header entry for this site, the site stops working. Looks like both the sites are not recognizing host header entries somehow.
0
 
LVL 29

Expert Comment

by:becraig
ID: 40025624
Can you edit the settings for both sites and send a print screen of host header configuration for each site ?
0
 

Author Comment

by:sandeepjadhav
ID: 40025682
Attached are the images. The Default website host header currently does not have host name as the site does not work if I mention the host name.
DefaultWebSite.png
Secondwebsite.png
0
 
LVL 29

Expert Comment

by:becraig
ID: 40026015
So here is what I would like you to do, on the computer you will test from:

edit c:\windows\system32\drivers\etc\host

add the following lines
      192.168.50.11       <site 1 full domain name here>
      192.168.50.11       <site 2 full domain name here>

Save that file

Then run (in a command prompt) :
nslookup  <site 1 full domain name here>
nslookup  <site 2 full domain name here>

Then edit the bindings for both sites to reflect the correct domain name and try loading the sites in a browser.

Give me the results for both steps (the browser output and the command output)
0
 

Author Comment

by:sandeepjadhav
ID: 40027917
I have attached the results of NS lookup which looks fine.

As far as browser output is concerned, the WS1.com is accessible when I make the hostheader entry. However ws2.com gives attached PHP error.

I am troubleshooting the PHP error, however in spite of PHP error the sites is accessible from the IP address/virtualfoldername
WS2Error.png
Nslookup.png
0
 
LVL 29

Expert Comment

by:becraig
ID: 40027926
You CANNOT access the site via ip address (if more than one site is configured on the same IP)  [This is by design].

They are BOTH bound to the same IP address you HAVE to call the site via host header.

How will IIS know what you are calling if 12 sites are on the same server (bound to the SAME IP) and you try to call them all by IP ?

That is the idea behind host headers, to allow IIS to know what you are really trying to reach.

If you want to get sites via IP w/o host headers then configure additional IP addresses.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Recursive Folder Upload via Web 5 79
removing hyperlinks from end-notes in a PDF to HTML conversion 8 107
Edit a page at wix.com 8 69
Where can I find... 1 43
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
A publishing tool, a Version Control System, or a Collaboration Platform! These can be some of the defining words for the two very famous web-hosting Git repositories: Bitbucket and Github. Git is widely used amongst the programmers and developers f…
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question