httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Meta Correio <>
Subject Fwd: FW: [users@httpd] Virtual Host Setup Help
Date Sat, 13 Feb 2016 18:10:35 GMT

Thank you very much for your reply.

I have two requests:

*http://serverone.tld <http://serverone.tld>http://1

On the first one the request header Host is:  “*Host: serverone.tld*”

And on the second one the request header Host is: “*Host:*”

Now, I have run the *httpd.exe –S* command and the result is as follows:


VirtualHost configuration:        is a NameVirtualHost

         default server serverone.tld (D:/Apache22/conf/httpd.conf:51)

         port 80 namevhost serverone.tld (D:/Apache22/conf/httpd.conf:51)

         port 80 namevhost (D:/Apache22/conf/httpd.conf:65)

So, I have one NameVirtualHost, This NVH has three
options: *default, serverone.tld and*.

The test that is failing is the one where “*Host:*”, so I will
focus on this one. It seems to me that the Apache server cannot match
the “*Host:*” with the ServerName (ServerName and, because
of this unexpected mismatch, it’s using the *default* virtual host for
serving the request.

A simple test that confirms my suspicion involves changing the virtual host
definition order in the configuration file:




    DocumentRoot "/Apache22/htdocs"
    ErrorLog "/Apache22/logs/"
    CustomLog "/Apache22/logs/" combined

    DocumentRoot "/Apache22/htdocs"
    ServerName serverone.tld
    ErrorLog "/Apache22/logs/serverone-error.log"
    CustomLog "/Apache22/logs/serverone -access.log" combined

Is this configuration, if one runs *httpd.exe –S*, the default server
changed (as expected).


VirtualHost configuration:        is a NameVirtualHost

         default server (D:/Apache22/conf/httpd.conf:60)

         port 80 namevhost (D:/Apache22/conf/httpd.conf:60)

         port 80 namevhost serverone.tld (D:/Apache22/conf/httpd.conf:67)

With the above *default* virtual hots set to **. the *http://1
<>*** request is logged under the “correct”
virtual host. Not because it’s matched. Just because the “correct” virtual
host for the request happens to be the *default*.

Now, let’s see if I understood your answer correctly. You mention that the
Host is compared to the address/hostname in the <virtualhost> itself. So, I
believe you are saying that when the host is “*Host:*” it is
compared to <VirtualHost> and that being a match with the
first defined virtual host, it stops searching other virtual hosts,
completely ignoring the ServerName field.

Is my reading your answer correctly?

Thank you.


*From:* Eric Covener [ <>]
*Sent:* Saturday, February 13, 2016 3:57 PM
*Subject:* Re: [users@httpd] Virtual Host Setup Help

On Sat, Feb 13, 2016 at 6:43 AM, Meta Correio <>

So, the question is, why does Apache place both requests under the same
Virtual Host when, on a scenario using Virtual Hosts under the
NameVirtualHost paradigm it should look at the Host: to decide what Virtual
Host to use.

​There is an under-ocumented, less used/understood matching step for NVH
where the Host is compared to the address/hostname in the <virtualhost>
itself. This is what messes with your test using the IP address.


Eric Covener

View raw message