Re: _default_ vs *, when do they differ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 - assuming you had a configuration where the Apache host has multiple IP addresses, and you would have multiple Listen directives for these multiple addresses, like e.g.
Listen 127.0.0.1:80
Listen 111.22.33.44:80
Listen 111.33.44.55:80
Listen 111.44.55.66:80
- then you would normally also have corresponding VHost sections as such :
<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.

To make things a bit more interesting, and still according strictly to the documentation, let's add a few name-based hosts to the above.
You could have this configuration :

Listen 127.0.0.1:80
Listen 111.22.33.44:80
Listen 111.33.44.55:80
Listen 111.44.55.66:80
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.
And adding a directive
NameVirtualHost *:80
would not make sense either, considering the already-present Listen and VirtualHost directives with addresses.

This is fun..



---------------------------------------------------------------------
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@xxxxxxxxxxxxxxxx
  "   from the digest: users-digest-unsubscribe@xxxxxxxxxxxxxxxx
For additional commands, e-mail: users-help@xxxxxxxxxxxxxxxx


[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux