Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Docs

Clarification on NameVirtualHost and VirtualHost sections

 

 

Apache docs RSS feed   Index | Next | Previous | View Threaded


mikeraz at patch

Sep 22, 2007, 8:43 AM

Post #1 of 4 (1034 views)
Permalink
Clarification on NameVirtualHost and VirtualHost sections

Hi,

I'd supply a patch, but I don't know which of:
http://httpd.apache.org/docs/2.0/mod/core.html#virtualhost
http://httpd.apache.org/docs/2.0/vhosts/name-based.html
http://httpd.apache.org/docs/2.0/vhosts/ ...
is appropriate.

I believe the statement:

If a <VirtualHost> block does not contain a ServerName statement the hostname
of the computer will be used.

Should be added.

Why?

It explains the default behavior.

If someone has a misconfigured VirtualHost it can possibly hijack the
configuration for the hostname defined VirtualHost.

Assume a configuration using
Include /etc/apache2/sites-enabled/[^.#]*
that has a, perhaps vendor supplied, 000-default or default that does not
have a ServerName specified. For example:

000-default or default file:
<VirtualHost *:80>
# No Server Name definition
DocumentRoot /var/www/
# ... other directives
</VirtualHost>

hostname.domain.tld file:
<VirtualHost *:80>
ServerName hostname.domain.tld
DocumentRoot /var/www/hostname
# ... other directives
</VirtualHost>

Contrary to their expectation the content stored at /var/www/hostname
would never be served. Instead the content at the DocumentRoot defined
in the 000-default or default file would be served.

Note, this could happen with any configuration where the file for
a misconfigured VirtualHost is loaded before the one containing the
definition where ServerName equals `hostname`.

Thank you for considering this suggestion.

--
Michael Rasmussen, Portland Oregon
Be appropriate && Follow your curiosity
http://www.patch.com/words/
The fortune cookie says:
Excuse me, but didn't I tell you there's NO HOPE for the survival of
OFFSET PRINTING?


---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe [at] httpd
For additional commands, e-mail: docs-help [at] httpd


joshua at slive

Sep 22, 2007, 1:39 PM

Post #2 of 4 (970 views)
Permalink
Re: Clarification on NameVirtualHost and VirtualHost sections [In reply to]

On 9/22/07, Michael Rasmussen <mikeraz [at] patch> wrote:
> Hi,
>
> I'd supply a patch, but I don't know which of:
> http://httpd.apache.org/docs/2.0/mod/core.html#virtualhost
> http://httpd.apache.org/docs/2.0/vhosts/name-based.html
> http://httpd.apache.org/docs/2.0/vhosts/ ...
> is appropriate.
>
> I believe the statement:
>
> If a <VirtualHost> block does not contain a ServerName statement the hostname
> of the computer will be used.

Not quite. It should be "Each <VirtualHost> block should contain a
ServerName. If it is absent, the ServerName from the main server
configuration will be used." That should probably go just in the
<VirtualHost> docs, since the name-based docs make is pretty-clear
that a ServerName is needed.

I have indeed stumbled into this myself while debugging someone's
configuration, so I agree it should be documented. I'll try to do it
myself.

Joshua.

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe [at] httpd
For additional commands, e-mail: docs-help [at] httpd


mikeraz at patch

Sep 22, 2007, 1:49 PM

Post #3 of 4 (958 views)
Permalink
Re: Clarification on NameVirtualHost and VirtualHost sections [In reply to]

Joshua Slive wrote:
> > If a <VirtualHost> block does not contain a ServerName statement the hostname
> > of the computer will be used.
>
> Not quite. It should be "Each <VirtualHost> block should contain a
> ServerName. If it is absent, the ServerName from the main server
> configuration will be used."

Unless there's no ServerName in the main server configuration. Then it pulls
the hostname. Ubunutu, for example, defaults to this situation.

> I have indeed stumbled into this myself while debugging someone's
> configuration, so I agree it should be documented. I'll try to do it
> myself.

Thank you.

--
Michael Rasmussen, Portland Oregon
Be appropriate && Follow your curiosity
http://www.patch.com/words/
The fortune cookie says:
La rosa tiene espinas, pero... ¿tiene pétalos el atún?
-- Roberto Fontanarrosa. Humorista argentino.


---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe [at] httpd
For additional commands, e-mail: docs-help [at] httpd


joshua at slive

Sep 24, 2007, 1:28 PM

Post #4 of 4 (953 views)
Permalink
Re: Clarification on NameVirtualHost and VirtualHost sections [In reply to]

On 9/22/07, Michael Rasmussen <mikeraz [at] patch> wrote:
> Joshua Slive wrote:
> > > If a <VirtualHost> block does not contain a ServerName statement the hostname
> > > of the computer will be used.
> >
> > Not quite. It should be "Each <VirtualHost> block should contain a
> > ServerName. If it is absent, the ServerName from the main server
> > configuration will be used."

Committed something like this to trunk and will backport to 2.2.

>
> Unless there's no ServerName in the main server configuration. Then it pulls
> the hostname. Ubunutu, for example, defaults to this situation.

It uses the default ServerName, which is indeed taken from the
hostname. This is actually an Ubuntu bug if they have no ServerName in
the main server context, because this forces Apache to do a reverse
DNS lookup at startup, needlessly placing a dependency on DNS.
All apache configs should have a main context ServerName, even if you
know it will never be used for anything.

Joshua.

---------------------------------------------------------------------
To unsubscribe, e-mail: docs-unsubscribe [at] httpd
For additional commands, e-mail: docs-help [at] httpd

Apache docs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.