Default webroot for unconfigured domain names.

I made a set up on CentOS 5.5 with Webmin and Virtualmin.

In webmin when I go to “Apache Webserver” I see:

Default Server Defines the default settings for all other virtual servers, and processes any unhandled requests.
Address Any
Port Any Server Name Automatic
Document Root /var/www/html

Virtual Server Handles the name-based server on address
Port 80 Server Name
Document Root /home/mydomain/public_html

First when I did not add a virtual server, the virtual server listing was not there (makes sense). When I requested a domain name that pointed to my server IP, eg, it showed me the content of /var/www/html, as expected since it says ‘any unhandled requests’.

However, after I added a virtual server in virtualmin for (not, the virtual server record at “Apache Webserver” was added. When I request (which is still not configured) it does not show me the content from /var/www/html as I would expect but it serves me the content from (/home/mydomain/public_html).

Did I misconfigure anything? Can I make it so that unconfigured domains show the content of ‘/var/www/html’? As it wouldnt make sense to see a site that doesn’t belong to the domain. (of course I could overcome it by creating a virtual server for the domain, however I would appreciate if the default would work in the meantime).

There is one caveat that I also fell for when I did tests in this regard, and which might help you too. :slight_smile:

There is a certain scheme with which Apache chooses which server handles requests to “unknown” domains". In general, it is the first configured virtual host. There are some exceptions to that though, which have to do with “how explicit” the definition of the host is. I can’t recall the precise rules at the moment, they should be in the Apache documentation.

Try setting the IP of the virtual server you wish to be the default one to “” instead of “any IP”.

Thanks. I think I should make one dummy virtual server then for this purpose. The /var/www/html doesn’t have a purpose anymore after using virtualmin virtual servers I suppose.

You can still use /var/www if you wish to, for the “catch-all-unknown” server. Just need to make sure to set the IP address, and not have any VMin virtual servers “prioritized”.

There is a function in VMin, Website Options / Default website for IP address, if you select that, the respective virtual server will be the catch-all one. VMin does that by giving the symlink in /etc/apache2/sites-enabled a name that has it appear first in the alphabetic order (starts with three zeroes if I recall correctly).

I couldn’t find it. I do not see anything called “Website Options”.

I’m sorry, it is in the tree under Server configuration. Missed that. :slight_smile:

I found it now. I think I had to activate the Virtualmin framed theme first (I was still running on the default webmin theme).