Creating a virtual host using webmin loads default site

Rooster242 picture Rooster242 · Jun 28, 2013 · Viewed 20.2k times · Source

So I'm trying to set up a rackspace cloud server to host multiple sites (not servers) with a single IP. I installed Virtualmin/Webmin on an Ubuntu 12.04 LTS server. I created the directory /var/www/sites/testsite. Then I created a virtual host under Webmin->Servers->Apache Webserver with the following settings:

Address: Any
Port: 80
Document Root: /var/www/sites/testsite
Server Name: testsite.com

Then, to test it, I edited the hosts file on my local machine and added

[my.server.ip.address] testsite.com

Then went to testsite.com in my browser and problem is it's loading the default site (at /var/www) instead of the virtual one I just created (I verfied this by adding different index.html files in /var/www and /var/www/sites/testsite).

Here are the directives webmin created in /etc/apache2/sites-available/webmin.1372454178.conf

DocumentRoot /var/www/sites/testsite
<Directory "/var/www/sites/testsite">
allow from all
Options +Indexes
</Directory>
ServerName testsite.com
ServerAlias www.testsite.com

Answer

Serban picture Serban · Nov 14, 2014

i fixed this by adding directive ServerAlias domain.tld *.domain.tld

You can find this for setup under Apache -> Your Virtual Domain settings -> Networking and Addresses -> Alternate virtual server names FIELD.

domain.tld *.domain.tld