Can't get virtual servers to work

In short: Added a virtual server (tried both via virtualmin and webmin’s Create virtual host) – when I access this domain, I still get routed to the default content in /var/www/

Setup: New Ubunto 10.04 install on EC2. Installed Virtualmin + Webmin via install.sh script.

Some debugging info from “Existing Virtual Hosts”:

Virtual Server	Any	80	Automatic	/var/www
Virtual Server	184.169.135.20	80	crossfitdata.com	/home/crossfitdata/public_html

From /etc/apache2/apache2.conf:

Include the virtual host configurations:

Include /etc/apache2/sites-enabled/
NameVirtualHost 184.169.135.20:80
<VirtualHost *:80>
DocumentRoot /var/www
<Directory “/var/www”>
allow from all
Options +Indexes

It looks like my new domain’s configuration is included @ /etc/apache2/sites-enabled/crossfitdata.com.conf

<VirtualHost 184.169.135.20:80>
SuexecUserGroup “#1001” “#1001
ServerName crossfitdata.com
ServerAlias www.crossfitdata.com
ServerAlias webmail.crossfitdata.com
ServerAlias admin.crossfitdata.com
DocumentRoot /home/crossfitdata/public_html
ErrorLog /var/log/virtualmin/crossfitdata.com_error_log
CustomLog /var/log/virtualmin/crossfitdata.com_access_log combined
ScriptAlias /cgi-bin/ /home/crossfitdata/cgi-bin/
ScriptAlias /awstats/ /home/crossfitdata/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /home/crossfitdata/public_html>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/crossfitdata/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/crossfitdata/fcgi-bin/php5.fcgi .php5

<Directory /home/crossfitdata/cgi-bin>
allow from all

RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.crossfitdata.com
RewriteRule ^(.) https://crossfitdata.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.crossfitdata.com
RewriteRule ^(.
) https://crossfitdata.com:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
IPCCommTimeout 31
Alias /dav /home/crossfitdata/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV on
AuthType Basic
AuthName “crossfitdata.com
AuthUserFile /home/crossfitdata/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
RemoveHandler .php
RemoveHandler .php5
RewriteEngine off


AuthName “crossfitdata.com statistics”
AuthType Basic
AuthUserFile /home/crossfitdata/.awstats-htpasswd
require valid-user

RedirectMatch /cgi-bin/mailman/([^/.])(.cgi)?(.) https://crossfitdata.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
RedirectMatch /mailman/([^/.])(.cgi)?(.) https://crossfitdata.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3

Can anyone give me some hints as to why this new domain isn’t getting routed to the content I put in /home/crossfitdata.com/public_html??

Thanks!

Howdy,

It looks like that default VirtualHost that’s in there is causing trouble… where it says this:

Virtual Server Any 80 Automatic /var/www

That “Any” will cause it to override other domains on the system.

My recommendation would be to either remove that VirtualHost altogether from Apache, or to edit it’s config file, and change the VirtualHost entry from this:

<VirtualHost *:80>

To this:

And then restart Apache.

-Eric

It looks like what you pasted in didn’t take?

I removed the “Any” line (so I only have a domain specific virtual server now). Now if I access the IP or the domain, I get the same 404 error:

Not Found

The requested URL / was not found on this server.

Am I still missing something?

Note:

/var/log/apache2/error.log shows both the IP direct access and the domain access both give this error:

[Sun Feb 19 18:48:07 2012] [error] [client 76.90.29.184] File does not exist: /htdocs

Clearly the routing is still not working…hmm!

Thanks much for any advice!

Removing the IP restriction to the specific domain made this work (for at least one domain). Adding another domain to verify. Any idea why (change from IP to ANY)?

Apache can be very picky about which virtual host it deems it has to use for a particular request. :slight_smile:

If you’re interested in the deeper details, there’s a good explanation for it in the Apache documentation: http://httpd.apache.org/docs/2.2/en/vhosts/details.html

I spoke too soon. Now all subdomains route to the first one (actionmeasurement)…

Virtual Server	Any	80	actionmeasurement.com	/home/actionmeasurement/public_html	Open..
Virtual Server	Any	Any	andyabramson.org	/home/andyabramson/public_html	Open..
Virtual Server	Any	80	crossfitdata.com	/home/crossfitdata/public_html Open...

Arg.