Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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>

share|improve this question
    
Interesting. Could you post an example of one of those *:443 virtualhosts that show up with -S? –  Andrew B Mar 9 '13 at 17:53
    
I have updated my post with two of the files defining the virtual hosts. –  user35042 Mar 10 '13 at 2:18
2  
Yeah, that's jacked up. Since the individual include files don't seem to have any weird conditional directives wrapping them, I'm inclined to focus on the main config itself now. Can you post the contents of the main httpd.conf to pastebin and share the URL? Don't forget to redact anything sensitive. –  Andrew B Mar 10 '13 at 5:40
add comment

3 Answers 3

up vote 1 down vote accepted

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.)

share|improve this answer
add comment

I use Debian Squeeze too, please see below how my ports.conf looks like.

The comment comes from the default file, note that you added NameVirtualHost *:443, I didn't.

NameVirtualHost *:80
Listen 80

<IfModule mod_ssl.c>
    # If you add NameVirtualHost *:443 here, you will also have to change
    # the VirtualHost statement in /etc/apache2/sites-available/default-ssl
    # to <VirtualHost *:443>
    # Server Name Indication for SSL named virtual hosts is currently not
    # supported by MSIE on Windows XP.
    Listen 443
</IfModule>

<IfModule mod_gnutls.c>
    Listen 443
</IfModule>

Note: in case you prefer to keep NameVirtualHost *:443 in ports.conf then you should add a link in order to have a default VirtualHost for 443 as follows:

ln -s /etc/apache2/sites-available/default-ssl /etc/apache2/sites-enabled/000-default-ssl

Then I would update /etc/apache2/sites-enabled/q2a by adding <Directory>...</Directory> (it's where you put some options, I completed your code by adding some examples).

<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

  <Directory /usr/share/question2answer>
    DirectoryIndex index.php

    # here you can also add some other options like:
    Options -Indexes FollowSymLinks MultiViews
    Order deny,allow
    Allow from all
    AllowOverride All
  </Directory>
</VirtualHost>

Finally I would change /etc/apache2/sites-enabled/tcert-dev by updating the document root in <Directory>...</Directory>.

<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 /srv/www/tools>
    AllowOverride None
  </Directory>
</VirtualHost>

I hope it helps.

share|improve this answer
    
The NameVirtualHost *:443 is the heart of the issue. I use that directive so that I can do do name-based virtual hosting over port 443. Otherwise, I would need one IP address for each virtual host. I cannot leave that directive out of my configuration. –  user35042 Mar 10 '13 at 14:30
    
Ok, I've updated my answer. –  Jules Mar 10 '13 at 15:06
add comment

That is a warning saying there are no virtualhosts setup for *:443

It would look something like

<virtualhost *:443>

</virtualhost>

If it doesn't match *:443 then it will throw that warning.

share|improve this answer
1  
But, as my post indicates, I have two virtual hosts setup to use 443. So the warning doesn't seem to be accurate. –  user35042 Mar 9 '13 at 17:04
    
yes but it's saying you didn't set them up correctly.. post the virtualhost configs then –  Mike Mar 9 '13 at 17:38
    
Posted the virtual host configs. –  user35042 Mar 10 '13 at 2:19
    
love how i get downvoted for a comment i made before he posted configs. –  Mike Mar 10 '13 at 15:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.