httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Covener" <cove...@gmail.com>
Subject Re: [users@httpd] _default_ vs *, when do they differ?
Date Mon, 12 Jan 2009 12:24:24 GMT
On Mon, Jan 12, 2009 at 5:51 AM, André Warnier <aw@ice-sa.com> wrote:
> Eric Covener wrote:
>>
>> Does anyone have a concrete example where the "_default_" and "*"
>> arguments to NameVirtualHost/VirtualHost behave different from
>> eachother?
>>
>> http://httpd.apache.org/docs/2.2/mod/core.html#virtualhost
>> http://httpd.apache.org/docs/2.2/vhosts/details.html
>>
> Whoever wrote these documentation pages seems to have been very, very
> thorough. But they are not really something "for the casual reader".
> Taking them at face value (which seems deserved here), it seems that
> _default_ is only really used with IP-based Vhosts, and never overlaps
> whatever NameVirtualHost covers.
> In other words (strictly following the doc pages and not by personal
> experience), it seems that

name-based vhost selection happens after ip-based, so they have to
interoperate. The doc is consistent in talking about _default_ for
ip-based and * for name-based, but I don't know if it's applicable
anymore.

experimentation shows (AFAICT) there's "more than" no difference
relative to matching an NVH. Normally, the NVH match has to be exact
(i.e. a * doesn't "match" a specific IP NVH), but _default_:80 is
covered by NVH *:80 and visa-versa.

> <VirtualHost 127.0.0.1:80>
> <VirtualHost 111.22.33.44:80>
> <VirtualHost 111.33.44.55:80>
> <VirtualHost 111.44.55.66:80>
> to catch requests arriving via connections to these distinct IP addresses.
> - But you could also have VHosts as follows :
> <VirtualHost _default_:80>
> <VirtualHost 111.22.33.44:80>
> <VirtualHost 111.33.44.55:80>
> and the "_default_" VHost would then catch requests arriving on both the
> 127.0.0.1 and 111.44.55.66 addresses.
>
> - while if you did not have this VHost
> <VirtualHost _default_:80>
> then the requests arriving on the addresses 127.0.0.1 and 111.44.55.66,
> would be handled using the "main" server configuration.

*:80 appears to do the same thing, though.


> NameVirtualHost 111.44.55.66:80
> <VirtualHost _default_:80>
> <VirtualHost 111.22.33.44:80>
> <VirtualHost 111.33.44.55:80>
>
> <VirtualHost 111.44.55.66:80>
>  Servername defaulthost
> </VirtualHost>
> <VirtualHost 111.44.55.66:80>
>  Servername name1.company.com
> </VirtualHost>
> <VirtualHost 111.44.55.66:80>
>  Servername name2.company.com
> </VirtualHost>
>
> and then :
> - requests arriving on the 111.44.55.66 interface would be handled as
> name-based VHosts, according to their "Host:" header, and default to
> "defaulthost" if the "Host:" header was absent, or did not match any of
> "name1.company.com" or "name2.company.com"
> - requests arriving on the other interfaces would be handled according to
> the interface they arrive on, as before, and use the _default_ VHost unless
> they arrive on the interfaces 111.22.33.44 or 111.33.44.55
>
> But, in such a configuration, specifying a VHost as
> <VirtualHost *:80>
> would not make sense, and probably generate an error at startup, because it
> does not match exactly any NameVirtualHost directive.

This does not generate errors. It matches any interface but doesn't
select based on ServerName/ServerAlias.

> And adding a directive
> NameVirtualHost *:80
> would not make sense either, considering the already-present Listen and
> VirtualHost directives with addresses.

Alone, this would generate a warning. With at least one virtualhost
matching exactly, it would work exactly as you want it.

Connections matching none of the specific IP addresses end up being
resolved to your set of VirtualHost *;80's, and then the Host: header
is used to select between them.


-- 
Eric Covener
covener@gmail.com

---------------------------------------------------------------------
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


Mime
View raw message