Solved

How do I host two websites on one IIS server.

Posted on 2014-04-22
16
244 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 28

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:Bing CISM / CISSP
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:
Bing CISM / CISSP 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
 

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:Bing CISM / CISSP
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 28

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:Bing CISM / CISSP
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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 

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 28

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 28

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 28

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 28

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
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.

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now