httpd-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stephen Shirley" <diam...@nonado.net>
Subject using mod_vhost_alias with normal vhosts
Date Wed, 30 Aug 2006 11:20:09 GMT
Hi,

(This concerns apache2.0, i've no idea if the other versions are affected too.)

I've discovered something that the vhosting docs don't seem to cover.
If you want to use both mod_vhost_alias (VirtualDocumentRoot et al)
and normal name-based vhosts (VirtualHost), you need to do something
like the following. For a server host.example.com, with an ip address
of 192.0.2.1:

-------------------------------8<--------------------------
NameVirtualHost 192.0.2.1:80

<VirtualHost 192.0.2.1:80>
   ServerName somethingwhichdoesntexist.example.com
    VirtualDocumentRoot /srv/%1/public_html
</VirtualHost>

<VirtualHost 192.0.2.1:80>
    ServerName www.example.com
    ServerAlias example.com host.example.com
    DocumentRoot /var/www/
</VirtualHost>
------------------------------->8--------------------------

This is type of setup isn't covered in the vhost docs at all that i
can see. Where it gets tricky is the ServerName entry for the first
VirtualHost. Without it, here's what happens:

    http://www.example.com, http://example.com are served from
/var/www as expected
    http://blah.example.com is served from /srv/blah/public_html, also
as expected
    http://host.example.com is served from /srv/host/public_html,
_not_ as expected.

Without a ServerName entry for the first VirtualHost, apache will
assign one from the reverse dns lookup for the ip, which points to
host.example.com. Adding an explicit ServerName for a garbage hostname
works around this, giving the following:

    http://www.example.com, http://example.com,
http://host.example.com are served from /var/www as expected
    http://blah.example.com is served from /srv/blah/public_html, also
as expected

Steve
--
"You are technically correct, the best kind of correct."
- Bureaucrat 1.0, Futurama

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe@httpd.apache.org
For additional commands, e-mail: docs-help@httpd.apache.org


Mime
View raw message