httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boyle Owen" <Owen.Bo...@swx.com>
Subject RE: Re[2]: [users@httpd] NameVirtualHost * with <VirtualHost IP>
Date Fri, 05 Dec 2003 08:27:37 GMT
> -----Original Message-----
> From: D Kelmi [mailto:miksir@laudlink.ru]
>
> >   Try this (notice two NameVirtualHost directives):
> > NameVirtualHost empty.somedomain.com
> > NameVirtualHost www.somedomain.com

First, can we correct the advice posted earlier. NameVirtualHost should
take an IP address as an argument - not a fully-qualified domain name.
If you give it an FQDN, it will "work" but only because apache resolves
the name to its IP. If you have any DNS problems, apache could fail to
start. 

To return to your misconfiguration problem; 

>> NameVirtualHost *
>> 
>> <VirtualHost *>
>>      DocumentRoot ...
>>      ServerName empty.somedomain
>> </VirtualHost>
>> 
>> <VirtualHost 1.2.3.4>
>>      DocumentRoot ...
>>      ServerName www.somedomain
>> </VirtualHost>
>> 
>>    But now for 1.2.3.4 run _ip-based_ virtual hosting. As result, for
>>    requests to 1.2.3.4 always answer second virtualhost.

IP-based VHs supersede name-based VHs so the apache behaviour you see is
exactly correct. Not a bug. 

>>    And more, if
>>    i add third virtualhost this 1.2.3.4 IP, apache generate warning
>>    about overlaps.

Of course it does. How is apache supposed to decide which VH to use if
they both have the same IP address? It is like you have two letter-boxes
with the same name on them. How can the postman decide which one to use?

>>    I think, that's wrong, because NameVirtualHost * say, what for
>>    all IP run name-based virtual hosting.

You are assuming that NameVirtualHost will take priority and that the
IP-based VH will live inside it somehow. If you think about it, that is
impossible.

You do not tell us how many IP addresses you have on your server. If
only one, then I guess you are trying to achieve the following:

	if hostname is set in request, do name-based VHing
	else
	use IP-VHing

The way to set that up is as follows:

NameVirtualHost 1.2.3.4
<VH 1.2.3.4>
  ServerName dummy
  DocumentRoot /path/to/default/site
</VH>
<VH 1.2.3.4>
  ServerName site_1
  DocumentRoot /path/to/site_1
</VH>
<VH 1.2.3.4>
  ServerName site_2
  DocumentRoot /path/to/site_2
</VH>
etc.

If the request matches site_1 or site_2, it will be served from the
correct VH. If it doesn't match, or doesn't contain a hostname, apache
will fall-back to the *first* VH in the list, which is the "dummy" site.

If you have many IP addresses, then simply separate them:

# IP-based site
<VH 1.2.3.4>
  ServerName ip_site
  DocumentRoot /path/to/default/site
</VH>

# name-based sites
NameVirtualHost 5.6.7.8
<VH 5.6.7.8>
  ServerName site_1
  DocumentRoot /path/to/site_1
</VH>
<VH 5.6.7.8>
  ServerName site_2
  DocumentRoot /path/to/site_2
</VH>

Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored. 

Diese E-mail ist eine private und persönliche Kommunikation. Sie hat
keinen Bezug zur Börsen- bzw. Geschäftstätigkeit der SWX Gruppe. This
e-mail is of a private and personal nature. It is not related to the
exchange or business activities of the SWX Group. Le présent e-mail est
un message privé et personnel, sans rapport avec l'activité boursière du
Groupe SWX.

This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please notify the sender urgently
and then immediately delete the message and any copies of it from your
system. Please also immediately destroy any hardcopies of the message.
You must not, directly or indirectly, use, disclose, distribute, print,
or copy any part of this message if you are not the intended recipient.
The sender's company reserves the right to monitor all e-mail
communications through their networks. Any views expressed in this
message are those of the individual sender, except where the message
states otherwise and the sender is authorised to state them to be the
views of the sender's company. 



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