httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tianyin Xu <>
Subject [users@httpd] Why the NameVirtualHost detective?
Date Fri, 30 Dec 2011 20:28:13 GMT
Hi, all,

First of all, Merry Xmas & Happy New Year!

I'm quite confused about the combination of the "NameVirtualHost" detective
and the <VirtualHost> block.

All the Manuals (e.g., [1], [2]) emphasize that "the argument to the
<VirtualHost> directive must exactly match the argument to the
NameVirtualHost directive." If a NameVirtualHost is defined without
corresponding <VirtualHost>, the following information will be shown:
        [warn] NameVirtualHost [IP]:[PORT] has no VirtualHosts

My question is on the other side: what will happen when a <VirtualHost> is
defined without NameVirtualHost? Some misconfiguration reports (e.g., [3])
can be found that a <VirtualHost> without NameVirtualHost declaration
doesn't work. For example, in [3]:



However, I cannot replay this case. When I configure my Apache like that,
both the two <VirtualHost> works. I checked the source code of different
Apache version including Apache 1.3.0, 1.3.42, and 2.2.21. Besides some
slight difference, the code of the virtual hosting is quite similar, as
follows (see apache-1.3.0/src/main/http-vhost.c or

Step 1. define a hash table: ipaddr_chain **iphash_table_tail[];
Step 2. Map the NameVirtualHosts into this hash table (i.e.,
Step 3. Go through the virtual hosts and put them into the hash table

Note that in Step 3, when getting a <VirtualHost>, Apache first tries to
find the NameVirtualHost with the same IP address in the hash table. If the
NameVirtualHost cannot be found, Apache will CREATE a new bucket containing
the virtual host information and add it into the hash table. This indicates
that even if the <VirtualHost> is defined without NameVirtualHost, it can
still work. Also, it comes the question: "Why we need the NameVirtualHost
detective?" and "Why it's necessary to make <VirtualHost> to match

Sorry. I'm a newbie to Apache and not very familiar with it. Any comments
and discussion will be highly appreciated!!!

Thanks a lot!!!

[1] Apache Documents,
[2] httpd wiki,

Best regards,

Tianyin XU,

View raw message