Multiple hosts on one IP problem

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Multiple hosts on one IP problem

Postby nealbapache » 31. August 2011 16:26

Hi -

I thought I had all directions correct for setting up multiple hosts. But something strange is happening.

In DNS, both sub-domains (site1.mydomain.com and site2.mydomain.com) are pointing to the same IP.

I'm on Win 2008 R2, using Joomla for my two sites.

When I go to http://site1.mydomain.com, everything works fine.
But when I go to http://site2.mydomain.com, I get a message from my browser saying "can't find the server at http://www.site2.mydomain.com". So, I'm not sure why it's trying to add the "www" to my subdomain on the second one.

At the bottom of my http.conf file, I have it setup like this:

########################################
# Setup virtual host web sites
NameVirtualHost *:80

# localhost - works fine
<VirtualHost *:80>
ServerAdmin myemail@abccorp.com
DocumentRoot "c:/xampp/htdocs"
ServerName localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>

# site 1 - works fine
<VirtualHost *:80>
ServerAdmin myemail@abccorp.com
ServerName site1.mydomain.com
DocumentRoot "C:/xampp/htdocs/site1"
ErrorLog logs/site1-error.log
CustomLog logs/site1.log combined
</VirtualHost>

# site 2 - doesn't work
<VirtualHost *:80>
ServerAdmin myemail@abccorp.com
ServerName site2.signonsystemsinc.com
DocumentRoot "C:/xampp/htdocs/site2"
ErrorLog logs/site2-error.log
CustomLog logs/site2.log combined
</VirtualHost>
########################################

In my Hosts file, I only have this:
127.0.0.1 localhost

I'm obviously missing something simple. Any suggestions would be appreciated.

Thanks,
Neal
nealbapache
 
Posts: 2
Joined: 31. August 2011 15:57

Re: Multiple hosts on one IP problem

Postby JonB » 31. August 2011 17:40

Well -

1st - although it 'may not be' an issue for you - vhosts should NOT be nested. you are effectively causing them to inherit properties. (and potentially creating .htaccess havoc.)

2nd :
uh geee

But when I go to http://site2.mydomain.com, I get a message from my browser saying "can't find the server at http://www.site2.mydomain.com".

ServerName site2.signonsystemsinc.com


And your browser is set to 'friendly URLs assist' or some such nonsense - when it can't find a domain, it tries to fix it.

Pray tell WHY do people keep installing XAMPP or WIndows SERVER packages - I just don't get it. :shock:

What ever

Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: Multiple hosts on one IP problem

Postby nealbapache » 31. August 2011 18:20

<< although it 'may not be' an issue for you - vhosts should NOT be nested. you are effectively causing them to inherit properties.>>

So, I must have the syntax incorrect. I didn't think I was nesting the vhosts.
Can you show me how this should look?

Also, to clarify, the last vhost should actually read like this:

<VirtualHost *:80>
ServerAdmin myemail@abccorp.com
ServerName site2.mydomain.com
DocumentRoot "C:/xampp/htdocs/site2"
ErrorLog logs/site2-error.log
CustomLog logs/site2.log combined
</VirtualHost>

Thanks,
Neal
nealbapache
 
Posts: 2
Joined: 31. August 2011 15:57

Re: Multiple hosts on one IP problem

Postby JonB » 31. August 2011 19:08

It isn't the syntax, its the location of the folders

Both the sites are under htdocs. i.e. they are a subset of your default server -

lets just say you went to the IP address of the default host... what would be served would be htdocs

lets say you typed in IPaddress/site1
you would be served the contents of site1
(as it is below htdocs)

ditto site2

If you plan to use .htaccess to secure things/do re-writes etc, don't nest sites, it will complicate your life.

You are welcome to test my hypothesis, I have pointed this out before in many forums. Its as true on IIS as it is on Apache. (although IIS it would be more unlilkely as it would be self-evident - you might even get a scream in IIS management - hmm I might have to test that)

maybe you wanted it that way

As for why doesn't your browser see site2???

A - is there anything to be served in site2?
B. - from a command prompt, try pinging site2's FQDN


Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 122 guests