You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Bryan Richardson <bt...@gmail.com> on 2007/12/17 04:44:06 UTC

[users@httpd] NameVirtualHost Directive

Hello all,

I'm curious as to why one would ever need to use the NameVirtualHost
directive in site configuration files.  I just can't seem to get my head
around why it's *sometimes* required.  I say sometimes only because I've
seen instances where it isn't used at all.  If all VirtualHost arguments
*must* match the IP address given with the NameVirtualHost directive, then
what's the point?

I learn best by example... can anyone give me an example of when it is
needed?

Thanks! -- BTR

Re: [users@httpd] NameVirtualHost Directive

Posted by Joshua Slive <jo...@slive.ca>.
On Dec 17, 2007 12:17 AM, Bryan Richardson <bt...@gmail.com> wrote:
> Hi Florian,
>
> Thanks for the response.  I guess my question is why have the
> NameVirtualHost directive since the *same* IP address is required to be
> specified as an attribute in the VirtualHost block?

It makes request processing more efficient for IP-based virtual hosts
if you need to specify explicitly when a host is name-based.

This way, for IP-based virtual hosts (ie, for any IP address that has
not been specified in a NameVirtualHost directive), apache doesn't
need to bother matching against the ServerName inside each
<VirtualHost> block, it can simply use the first block that matches
the IP address/port.

Joshua.

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


Re: [users@httpd] NameVirtualHost Directive

Posted by fl...@tramsch.de.
Maybe I missed the core of your question because it was so early in the
morning for me :-)

To extend my example:

NameVirtualHost IP1:80
<VirtualHost IP1:80>
  ServerName domain1.com
  DocumentRoot /var/www/domain1/
  ....
</VirtualHost>

<VirtualHost IP1:80>
  ServerName domain2.com
  DocumentRoot /var/www/domain2/
  ....
</VirtualHost>

NameVirtualHost IP2:80
<VirtualHost IP2:80>
  ServerName domain3.com
  DocumentRoot /var/www/domain3/
  ....
</VirtualHost>

Now the apache decides which website to serve only via the domain name that is
given with the request.
Literally speaking, if you read an NameVirtualHost statement like "I want a
virtual host on that IP and on that port to exist", then a VirtualHost
statement would mean "here is a configuration for ONE domain running under
that virtualhost". That's why they have to have the same name and why a
virtualhost needs a ServerName.

I hope that was a little bit more precise.

bye
Florian

On Mon, December 17, 2007 06:17, Bryan Richardson wrote:
> Hi Florian,
>
> Thanks for the response.  I guess my question is why have the
> NameVirtualHost directive since the *same* IP address is required to be
> specified as an attribute in the VirtualHost block?
>
> Thanks! -- BTR
>
> On Dec 16, 2007 10:09 PM, <fl...@tramsch.de> wrote:
>
>> Hi Bryan,
>>
>> one example would be a machine with two IP adresses, each of them has its
>> own
>> www.domain
>>
>> example:
>>
>> NameVirtualHost IP1:80
>> <VirtualHost IP1:80>
>>  ....
>> </VirtualHost>
>>
>> NameVirtualHost IP2:80
>> <VirtualHost IP2:80>
>>  ....
>> </VirtualHost>
>>
>> but there are even more situations where NameVirtualHost could used. Maybe
>> with different websites on different ports, etc.
>>
>> bye
>> Florian
>>
>>
>> On Mon, December 17, 2007 04:44, Bryan Richardson wrote:
>> > Hello all,
>> >
>> > I'm curious as to why one would ever need to use the NameVirtualHost
>> > directive in site configuration files.  I just can't seem to get my head
>> > around why it's *sometimes* required.  I say sometimes only because I've
>> > seen instances where it isn't used at all.  If all VirtualHost arguments
>> > *must* match the IP address given with the NameVirtualHost directive,
>> then
>> > what's the point?
>> >
>> > I learn best by example... can anyone give me an example of when it is
>> > needed?
>> >
>> > Thanks! -- BTR
>> >
>>
>>
>>
>> ---------------------------------------------------------------------
>> 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


Re: [users@httpd] NameVirtualHost Directive

Posted by Vasiliy Boulytchev <va...@linuxspecial.com>.
The meaning of NameVirtualHost is used for other reasons as well.

Sent from my iPhone

On Dec 17, 2007, at 0:17, "Bryan Richardson" <bt...@gmail.com> wrote:

> Hi Florian,
>
> Thanks for the response.  I guess my question is why have the  
> NameVirtualHost directive since the *same* IP address is required to  
> be specified as an attribute in the VirtualHost block?
>
> Thanks! -- BTR
>
> On Dec 16, 2007 10:09 PM, <fl...@tramsch.de> wrote:
> Hi Bryan,
>
> one example would be a machine with two IP adresses, each of them  
> has its own
> www.domain
>
> example:
>
> NameVirtualHost IP1:80
> <VirtualHost IP1:80>
>  ....
> </VirtualHost>
>
> NameVirtualHost IP2:80
> <VirtualHost IP2:80>
>  ....
> </VirtualHost>
>
> but there are even more situations where NameVirtualHost could used.  
> Maybe
> with different websites on different ports, etc.
>
> bye
> Florian
>
>
> On Mon, December 17, 2007 04:44, Bryan Richardson wrote:
> > Hello all,
> >
> > I'm curious as to why one would ever need to use the NameVirtualHost
> > directive in site configuration files.  I just can't seem to get  
> my head
> > around why it's *sometimes* required.  I say sometimes only  
> because I've
> > seen instances where it isn't used at all.  If all VirtualHost  
> arguments
> > *must* match the IP address given with the NameVirtualHost  
> directive, then
> > what's the point?
> >
> > I learn best by example... can anyone give me an example of when  
> it is
> > needed?
> >
> > Thanks! -- BTR
> >
>
>
>
> ---------------------------------------------------------------------
> 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
>
>

Re: [users@httpd] NameVirtualHost Directive

Posted by Bryan Richardson <bt...@gmail.com>.
Hi Florian,

Thanks for the response.  I guess my question is why have the
NameVirtualHost directive since the *same* IP address is required to be
specified as an attribute in the VirtualHost block?

Thanks! -- BTR

On Dec 16, 2007 10:09 PM, <fl...@tramsch.de> wrote:

> Hi Bryan,
>
> one example would be a machine with two IP adresses, each of them has its
> own
> www.domain
>
> example:
>
> NameVirtualHost IP1:80
> <VirtualHost IP1:80>
>  ....
> </VirtualHost>
>
> NameVirtualHost IP2:80
> <VirtualHost IP2:80>
>  ....
> </VirtualHost>
>
> but there are even more situations where NameVirtualHost could used. Maybe
> with different websites on different ports, etc.
>
> bye
> Florian
>
>
> On Mon, December 17, 2007 04:44, Bryan Richardson wrote:
> > Hello all,
> >
> > I'm curious as to why one would ever need to use the NameVirtualHost
> > directive in site configuration files.  I just can't seem to get my head
> > around why it's *sometimes* required.  I say sometimes only because I've
> > seen instances where it isn't used at all.  If all VirtualHost arguments
> > *must* match the IP address given with the NameVirtualHost directive,
> then
> > what's the point?
> >
> > I learn best by example... can anyone give me an example of when it is
> > needed?
> >
> > Thanks! -- BTR
> >
>
>
>
> ---------------------------------------------------------------------
> 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
>
>

Re: [users@httpd] NameVirtualHost Directive

Posted by fl...@tramsch.de.
Hi Bryan,

one example would be a machine with two IP adresses, each of them has its own
www.domain

example:

NameVirtualHost IP1:80
<VirtualHost IP1:80>
  ....
</VirtualHost>

NameVirtualHost IP2:80
<VirtualHost IP2:80>
  ....
</VirtualHost>

but there are even more situations where NameVirtualHost could used. Maybe
with different websites on different ports, etc.

bye
Florian


On Mon, December 17, 2007 04:44, Bryan Richardson wrote:
> Hello all,
>
> I'm curious as to why one would ever need to use the NameVirtualHost
> directive in site configuration files.  I just can't seem to get my head
> around why it's *sometimes* required.  I say sometimes only because I've
> seen instances where it isn't used at all.  If all VirtualHost arguments
> *must* match the IP address given with the NameVirtualHost directive, then
> what's the point?
>
> I learn best by example... can anyone give me an example of when it is
> needed?
>
> Thanks! -- BTR
>



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


RE: [users@httpd] NameVirtualHost Directive

Posted by Axel-Stephane SMORGRAV <Ax...@europe.adp.com>.
NameVirtualHost is used only if you want to host several web sites using the same IP/port combination as opposed to IP-based virtual hosting where exactly one site (server name) is hosted on each IP/port combination.

If you use Name-based virtual hosting, you may provide several VirtualHost sections for the IP/port combination declared as NameVirtualHost. In that case Apache will compare the Host-header of the request with the ServerName of the name-based virtual hosts. If one matches, the request will be processed in the context of that virtual host. If none match, the context of the first virtual host declared for that IP/port will be used.

You can very well mix name-based and IP-based virtual hosting in the same Apache server.

See http://httpd.apache.org/docs/2.2/vhosts/name-based.html.

-ascs
________________________________

De : Bryan Richardson [mailto:btricha@gmail.com] 
Envoyé : lundi 17 décembre 2007 04:44
À : users@httpd.apache.org
Objet : [users@httpd] NameVirtualHost Directive


Hello all,

I'm curious as to why one would ever need to use the NameVirtualHost directive in site configuration files.  I just can't seem to get my head around why it's *sometimes* required.  I say sometimes only because I've seen instances where it isn't used at all.  If all VirtualHost arguments *must* match the IP address given with the NameVirtualHost directive, then what's the point? 

I learn best by example... can anyone give me an example of when it is needed?

Thanks! -- BTR


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