You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Matthew Williamson <ma...@virgin.net> on 2004/03/24 20:10:28 UTC

[users@httpd] Virtual Hosts

Good evening,

I have 2 machines, and have just re-built one as a stand alone server,
it is running on an IP address of 192.168.0.2 host name pentium, my
machine which connects directly to it via crossover cable has an IP
address of 192.168.0.1, host name www.linuxbox.com and i am using this
machine for developing applications on and save the info to my server. 
I have created 2 virtual hosts on the pentium box which is a server, but
every time I connect to the box with just the IP address 192.168.0.2 I
get the first virtual hosts index page showing in my web browser.  If i
type 192.168.0.2/reays/index.html which should drill down into the
virtual host which is named reays I get a object not found?  this also
happens if I replace reays with my other virtual host testbox.  My hosts
file on the server contains the following hosts

192.168.0.2 pentium pentium.localdomain localhost
127.0.0.1 www.reays.com reays.localdomain localhost
127.0.0.1 www.testbox.com testbox.localdomain localhost
192.168.0.1 www.linuxbox.com 

Is it that I have something wrong in my hosts file, or should I be
looking at my http.conf to change my virtual host settings?

Best Regards

'Newbie' Matt


---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Virtual Hosts

Posted by Todd Weaver <to...@m2n.com>.
On Wed, Mar 24, 2004 at 07:10:28PM +0000, Matthew Williamson wrote:
> 192.168.0.2 pentium pentium.localdomain localhost
> 127.0.0.1 www.reays.com reays.localdomain localhost
> 127.0.0.1 www.testbox.com testbox.localdomain localhost
> 192.168.0.1 www.linuxbox.com 
> 
> Is it that I have something wrong in my hosts file, or should I be
> looking at my http.conf to change my virtual host settings?

VirtualHosts are sequentially read.
And if there is no match for VirtualHosts to distinguish which one
you're wanting to use, the first is used.

Your example:
<VirtualHost 192.168.0.2:80>
        ServerName pentium.localdomain.com
        ...
</VirtualHost>

<VirtualHost 192.168.0.2:80>
        ServerName reays.localdomain.com
        ...
</VirtualHost>

<VirtualHost 192.168.0.2:80>
        ServerName third.localdomain.com
        ...
</VirtualHost>

if you request:
http://192.168.0.2/
You will get the first VirtualHost, because httpd cannot
distinguish which one you 'really' want.

The common distinguishing factor is ServerName.
so if you request:
http://reays.localdomain.com/
(and have that setup in your hosts properly to point
 to your httpd server!)
You would get the second VirtualHost,
since httpd CAN distinguish which
one you 'really' wanted.

1. So you most likely need to change your VirtualHosts
   to include ServerName.
2. You most likely need to change your host file to point
   to pentium for each ServerName.
3. And you would most likely want to change your request
   url from IP address based, to named based.

Todd.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org


Re: [users@httpd] Virtual Hosts

Posted by Chip Cuccio <ch...@norlug.org>.
* Chip Cuccio <ch...@norlug.org>
  |__ Wed, Mar 24, 2004 at 01:26:22PM -0600:
> Do you have valid DNS entires for your virtual hosts set up?

Assuming that you are doing name-based virtual hosts, that is ;-)

-- 
Chip Cuccio                    |  <ch...@norlug.org>
NORLUG VP and Sysadmin         |  <http://norlug.org/~chipster/>
Northfield Linux Users' Group  |  Northfield, Minnesota USA


Re: [users@httpd] Virtual Hosts

Posted by Chip Cuccio <ch...@norlug.org>.
* Matthew Williamson <ma...@virgin.net>
  |__ Wed, Mar 24, 2004 at 07:10:28PM +0000:
> Is it that I have something wrong in my hosts file, or should I be
> looking at my http.conf to change my virtual host settings?

Do you have valid DNS entires for your virtual hosts set up?

-- 
Chip Cuccio                    |  <ch...@norlug.org>
NORLUG VP and Sysadmin         |  <http://norlug.org/~chipster/>
Northfield Linux Users' Group  |  Northfield, Minnesota USA