virtual host question

Hi -
I’ve got a new install of opensuse11 and I am trying to get named virtual hosts configured. I’ve got one ip, with an a record and a couple aliases.

I’ll call them site1 and site2

Apache is up and running and serves out web requests to site1.
However, when I type in the URL for site2, site1 actually shows up.

my listen.conf file has been changed to show:

NameVirtualHost *:80

Then in my httpd.conf file I have:

Include /etc/arache2/default-server.conf

Then in /vhosts.d/ I have two files I created:

001_defaultweb.conf and 002_help.conf

default web is copied from the template and has the following info (truncated):

<VirtualHost *:80>

    # DocumentRoot: The directory out of which you will serve your
    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    DocumentRoot /srv/www/htdocs

and then the 002_help.conf file has the following:

<VirtualHost *:80>
 DocumentRoot /srv/www/vhosts/site2

Somewhere things are not getting parsed correctly. Https2 -S shows:

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80                   is a NameVirtualHost
         default server (/etc/apache2/vhosts.d/001_defaultweb.conf:15)
         port 80 namevhost
         port 80 namevhost (/etc/apache2/vhosts.d/002_help.conf:1)
Syntax OK

Any ideas why site2 won’t show? Do I need to edit httpd.conf and not point to default-servers.conf?

Seems like this should be easy to configure…


Are you using any kind of URL redirection service provided by a dynamic DNS provider? That won’t work for the purpose of virtual hosting since they will not preserve the Host: header line but send you to the IP address.

You could look in your access log to see what was the host asked for when site2 is accessed. If desperate you could use wireshark to look at the incoming HTTP request.