Hi,
Seems to me what users have the most problem groking is the duplicate of
the main host in httpd.conf and it needing to be the first vhost. In the
docs it is highlighted as "Main server goes away." In reality, this is
not always the case, sometimes people just get the main host and nothing
else.
There is not a month that goes by on the Apache Lounge forum that this
does not get requests for help. It's explained on there many times but
most seem incapable of using the search function.
The docs are misleading cause right after they see the warning, which
they do not understand in most cases, the example doesn't show it. How
is a noob supposed to know that this is in reality the same
hostname/docroot et al from httpd.conf or whatever the name of the file
is on whatever flavor of OS;
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.domain.tld
ServerAlias domain.tld *.domain.tld
DocumentRoot /www/domain
</VirtualHost>
I see how it is explained and I understand it clearly, but I've been
tinkering with Apache since 1.3.0 before that warning was ever added to
the docs. I also can not think of any better to way to explain it other
than literally showing it in in example.
If in your httpd.conf file you have;
ServerName bla.bla
...
DocumentRoot /path/to/bla
then in your virtual host file you need;
NameVirtualHost *:80
# Duplicate of our main host is needed so that virtual hosting
# works as it is supposed to
<VirtualHost *:80>
ServerName bla.bla
DocumentRoot /path/to/bla
</VirtualHost>
# Now we can add all other hosts below
<VirtualHost *:80>
ServerName foo.foo
DocumentRoot /path/to/foo
...
</VirtualHost>
<VirtualHost *:80>
ServerName bar.bar
DocumentRoot /path/to/bar
...
</VirtualHost>
Just my two cents since you brought the subject up :)
Cheers,
Gregg
Eric Covener wrote:
... and assume overlaps are intentional opt-in to name-based vhosts?
The selection algorithm would not change, meaning you'd still only be
selecting from the best ip-based match.
We'd lose the warning about overlapping vhosts, and maybe incur some
overhead on mapping a vhost that was unintentionally showing up
multiple times.
Just kicking the idea around since NVH seems to be tough for users to grok.