Apache2 vhosts not responding on ServerName directive

1

I have an apache instance running on Debian squeeze, with two virtual hosts defined (including a redirect from port 80 to port 443. There are two Vhosts listening to port 80, and one of the named vhosts redirects to port 443.

What happens: visit http://aspen.findyourtrees.net and receive the expected unfinished WordPress template for the www site

visit https://qat.quoteatree.com and expect to see the login form for the secured web app ... but instead the browser returns a server not responding error. (note the https scheme)

visit https://aspen.findyourtrees.net and I see the login form I would expect to see for https://qat.quoteatree.com (note the https scheme)

I can not for the life of me figure out the configuration problem that prevents the server from responding to queries for qat.quoteatree.com

So this is my apache configuration (Server version: Apache/2.2.16 (Debian))

aspen:/etc/apache2# cat ports.conf
#This file generated via template by Chef.
Listen 80
NameVirtualHost *:80

Listen 443
NameVirtualHost *:443


aspen:/etc/apache2# cat ./sites-enabled/wordpress.conf
<VirtualHost *:80>
  ServerName aspen.findyourtrees.net
  ServerAlias www.quoteatree.com

  DocumentRoot /var/www/wordpress

  <Directory /var/www/wordpress>
    ...
  </Directory>

  <Directory />
    ...
  </Directory>

  RewriteEngine On
</VirtualHost>


aspen:/etc/apache2# cat ./sites-enabled.qat.conf
<Proxy *>
Order allow,deny
Allow from all
</Proxy>

<VirtualHost *:80>
ServerName qat.quoteatree.com
Redirect / https://qat.quoteatree.com:443/
</VirtualHost>

<VirtualHost *:443 %>
ServerName  qat.quoteatree.com
ServerAdmin ops@findyourtrees.com

SSLEngine On
SSLCertificateFile /etc/apache2/ssl/apache.pem
SSLCertificateKeyFile /etc/apache2/ssl/apache.key

ProxyPass / http://localhost:8080/ 
ProxyPassReverse / http://localhost:8080/
</VirtualHost>

a dump of what apache thinks the vhosts are:

 aspen:/etc/apache2# apachectl -t -D DUMP_VHOSTS
 [Mon Dec 19 23:44:03 2011] [error] (EAI 2)Name or service not known: Could not resolve    
 host name % -- ignoring!
 VirtualHost configuration:
 wildcard NameVirtualHosts and _default_ servers:
 *:443                  is a NameVirtualHost
     default server qat.quoteatree.com (/etc/apache2/sites-enabled/qat.conf:11)
     port 443 namevhost qat.quoteatree.com (/etc/apache2/sites-enabled/qat.conf:11)
 *:80                   is a NameVirtualHost
     default server qat.quoteatree.com (/etc/apache2/sites-enabled/qat.conf:6)
     port 80 namevhost qat.quoteatree.com (/etc/apache2/sites-enabled/qat.conf:6)
     port 80 namevhost aspen.findyourtrees.net (/etc/apache2/sites-enabled/wordpress.conf:1)
Syntax OK

lhagemann

Posted 2011-12-20T00:21:55.880

Reputation: 286

1What's with the % on the VirtualHost directive definition? – Garrett – 2011-12-20T00:58:21.633

@gman --- that is a great question, assuming you mean the message from the DUMP_VHOSTS output. As you can see in my host configurations, there is nothing that explains it. I can not find anything that references it or explains it. I have a test server (with different domains) set up, and the conf files are exactly the same (except the domain names) and the '% host name' message appears there too. But, that configuration works. – lhagemann – 2011-12-20T01:28:42.110

No you actually have one in your quoted ports.conf file. <VirtualHost *:443 %> – Garrett – 2011-12-20T01:59:02.107

oh, thanks gman, didn't see that. (and the problem was that I had something in my /etc/hosts file that was overriding dns. That makes me feel really silly. – lhagemann – 2011-12-20T06:38:27.253

Answers

0

This is embarrassing, but the problem was in my /etc/hosts file all along.

lhagemann

Posted 2011-12-20T00:21:55.880

Reputation: 286