You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Antoine PICOLET <an...@sagem.com> on 2004/10/01 09:41:33 UTC

[users@httpd] Réf. : Re: [users@httpd] NameVirtualHostDefaults

A _default_ virtual host is never used for NameVirtualHosts. If you 
declare something like :

NameVirtualHost 192.168.0.100:80

<VirtualHost 192.168.0.100:80>
ServerName a.site.com
[... snip ...]
</VirtualHost>

<VirtualHost 192.168.0.100:80>
ServerName b.site.com
[... snip ...]
</VirtualHost>


then the 'default' Virtual Host is the first of the list (a.site.com). 
_default_ virtual hosts are only used with IP-based vhosting, such as :

Listen *:90

<VirtualHost 1.1.1.1:90>
ServerName a.site.com
[... snip ...]
</VirtualHost>

<VirtualHost 2.2.2.2:90>
ServerName a.site.com
[... snip ...]
</VirtualHost>

<VirtualHost _default_:90>
ServerName default.site.com
[... snip ...]
</VirtualHost>

In tom's case, using Name Virtual Hosts, specifying a default Virtual 
Host, mapped to any request not covered by others, is as simple as 
specifying it as the first in the list. I personnaly use a 'fake' Virtual 
Host, rejecting everyone, as the first, which looks like that:

<VirtualHost 192.168.0.100:80>
ServerName site.com
<Directory "/">
deny from all
</Directory>
</VirtualHost>


Antoine







Mark McCulligh <mm...@visualtech.ca>

30/09/2004 23:38
Veuillez répondre à users
Remis le : 30/09/2004 23:43

 
        Pour :  users@httpd.apache.org
        cc :    (ccc : Antoine PICOLET/DRD/SAGEM)
        Objet : Re: [users@httpd] NameVirtualHost Defaults



Thomas C. Meggs wrote:

>On Thu, Sep 30, 2004 at 05:00:59PM -0400, Mark McCulligh wrote:
> 
>
>>You are right in your assumption. If you have vhost using the same IP 
>>address and someone ask for a domain name that is not found to have its 
>>own vhost record it will load the first vhsot record with that IP 
address.
>>
>>I would use |ServerAlias:
>>|
>>
>><VirtualHost *:80>
>>ServerName c.site.com
>>ServerAlias d.site.com
>>[... snip ...]
>></VirtualHost>
>>
>>I wouldn't do the _default_ method personally.  Using ServerAlias will 
>>keep you vhost record easy to read and know what will link to what. Just 

>>my two cents.
>> 
>>
>
>Hi Mark,
>
>Thanks for your response.
>
>In my case, I would really like there to be a default site that
>answers to any request not covered by a VirtualHost directive.
>
>Idealy that site would not be the first alphabetical hostname,
>but rather one that I specify. I would like to do this for both
>ports 80 and 443 under one instance of apache2.
>
>Are you familiar with any way to accomplish this? I was under the
>assumption that using <VirtualHost _default_> would accomplish
>this, but it doesn't seem to be the case.
>
>Tom
> 
>
 From my understanding of the _default_ it will caught unmatched IP 
addresses

Example:

<VirtualHost 192.168.0.100:80>
ServerName a.site.com
[... snip ...]
</VirtualHost>

<VirtualHost 192.168.0.100:80>
ServerName b.site.com
[... snip ...]
</VirtualHost>

<VirtualHost _default_:80>
[... snip ...]
</VirtualHost>

If the domain name with IP address 192.168.0.101 came into the server it 
will use the _default_ vhost.

But if c.site.com with IP address 192.168.0.100 came in it would use the 
first vhost with IP address 192.168.0.100. Which is a.site.com

I am not 100% sure this is how it work as I have not tested this out. 
But I think this is what happens.

Mark.


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





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