Ssl – NameVirtualHost *:443 has no VirtualHosts on debian squeeze

apache-2.2debian-squeezenamevirtualhostssl

I have an Apache 2.2 server that works but I am getting the NameVirtualHost *:443 has no VirtualHosts warnings when restarting. But I do have VirtualHosts that match *:443.

The system is Debian squeeze. The ports.conf file looks like this:

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
   NameVirtualHost *:443
   Listen 443
</IfModule>

Here is the output when running the -S option with apache2ctl:

% /usr/sbin/apache2ctl -S 
[Sat Mar 06 10:07:11 2013] [warn] NameVirtualHost *:443 has no VirtualHosts
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:443                  is a NameVirtualHost
         default server q2a-dev.example.org (/etc/apache2/sites-enabled/q2a:1)
         port 443 namevhost q2a-dev.example.org (/etc/apache2/sites-enabled/q2a:1)
         port 443 namevhost tcert-dev.example.org (/etc/apache2/sites-enabled/tcert-dev:1)
*:80                   is a NameVirtualHost
         default server emailtest-dev.example.org (/etc/apache2/sites-enabled/emailtest:1)
         port 80 namevhost emailtest-dev.example.org (/etc/apache2/sites-enabled/emailtest:1)
Syntax OK

The two virtual hosts are defined in files living in /etc/apache2/sites-enabled:

# /etc/apache2/sites-enabled/q2a
<VirtualHost *:443>
  DocumentRoot /usr/share/question2answer
  ServerName q2a-dev.example.org
  ServerAlias q2a-dev

  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/q2a-dev.pem
  SSLCertificateKeyFile /etc/ssl/private/q2a-dev.key

  DirectoryIndex index.php
</VirtualHost>

and here is the another one:

# /etc/apache2/sites-enabled/tcert-dev
<VirtualHost *:443>
  DocumentRoot /srv/www/tools
  ServerName tcert-dev.example.org
  ServerAlias tcert-dev

  SSLEngine on
  SSLCertificateFile /etc/ssl/certs/tcert-dev.pem
  SSLCertificateKeyFile /etc/ssl/private/tcert-dev.key

  <Directory "/">
    AllowOverride None
  </Directory>
</VirtualHost>

Best Answer

I found the problem. After Andrew B suggested posting more of the configuration on pastebin I looked through all the files more carefully and found that I had TWO places where the NameVirtualHost *:443 directive appeared: one in ports.conf and one in a file in the directory /etc/apache2/conf.d all files of which are loaded during Apache start-up.

I removed one of the instances and the warning went away.

(Note that this whole issue goes away in Apache 2.4 as NameVirtualHost is implicit for address/port combinations appearing in multiple virtual hosts.)