httpd-bugs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject DO NOT REPLY [Bug 51709] New: ServerName/ServerAlias don't work if Host: header from HTTP request matches VirtualHost address
Date Tue, 23 Aug 2011 08:14:03 GMT

             Bug #: 51709
           Summary: ServerName/ServerAlias don't work if Host: header from
                    HTTP request matches VirtualHost address
           Product: Apache httpd-2
           Version: 2.2.19
          Platform: PC
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core
    Classification: Unclassified

As discussed on the mailing list, the following issue was found:

Short summary:
If it matches, the parameter from VirtualHost overrides any ServerName or
ServerAlias directive. Under some rare conditions, content for the wrong
virtual host is delivered.

Detailed description:
I have configuration with two virtual hosts v1 and v2, both listening on
the same IP address. Assuming that v1.local and v2.local both resolve to the IP
address, the configuration for the virtual hosts basically
looks like this:

Listen: http
<VirtualHost v2.local:80>     # <-- this is NO typo!
    ServerName v1.local
    DocumentRoot /srv/v1
<VirtualHost v2.local:80>
    ServerName v2.local
    DocumentRoot /srv/v2

For HTTP requests with the request header 'Host: v2.local:80', the
request always ends up on virtual host v1, delivering the content from

Reading the code (version 2.2.19) I discovered, that in the function
check_hostalias() defined in server/vhost.c the host header is
matched against the parameter from the VirtualHost container first,
before it is then matched against any ServerName or ServerAlias
directive. And as soon as the first VirtualHost seems to match, no
ServerName or ServerAliases are checked. So, essentially any name or IP
literal specified as parameter to VirtualHost seems to have precedence
over all ServerName or ServerAlias directives.

I've already consulted the SVN history. Apparently this code flow didn't
change since the NameVirtualHost directive was added (SVN Rev. 79345)
back in October 1997, and maybe is even older.

Configure bugmail:
------- You are receiving this mail because: -------
You are the assignee for the bug.

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message