Apache serves wrong virtualhosts

OS type and version Debian 11
Virtualmin version Latest

Hi all, I was wondering if you had any idea as to why this may be happening.

I currently have virtualmin/webmin installed on a Debian machine which I use as a mail server for mutliple domains. The server has a hostname root.server.com, I have setup a virtualhost for root.server.com which is accessible from the internet. I use this vhost to obtain a SSL certificate from lets encrypt for the server. I use this for webmin as well as core services such as postfix, dovecot etc. This vhost has an apache website enabled but dns disabled as I host the DNS records elsewhere. The issue arises when I add more domains. If I add domain1.com and configure it to only receive mail (website and dns disabled) then if I got to domain1.com it serves root.domain.com files in public_html. Is this meant to be happening? I have disabled domain1.com’s website so nothing should be served or am I wrong? Is there any way to disable this? The email server works but this is just annoying and would be nice to get rid off.

Any help would be much appreciated, thanks in advance.


If you point a domain to the IP address of the server, and Apache does not have a website for the domain, it’ll serve up the “default” website which is typically the one setup first. So it’s serving up “root.server.com” since “domain1.com” does NOT have a website setup.

If you don’t want to serve up a website, don’t add an A record at your DNS provider to the server for “domain1.com”.

If you just want “domain1.com” to receive email…

Setup an MX record like:



10 root.server.com

This will tell the internet that mail destined for “domain1.com” should be sent to “root.server.com

You can the setup your mail client with the following IMAP/POP and SMTP hostname.


The only records in your DNS would be:

NS - where the domain gets its records from
MX - the server which receives email
TXT - potentially an SPF, DKIM, and/or DMARC record

Let us know if this helps, or if you require further direction.

Hi there thank you very much, I now understand. The thing which confused me was the DNS MX record I always though it had to point to the Apache Vhost for the domain I didnt know it could point to the root server itself. Anyways we learn. Thank you for your help, I now have a fully working email server on a residential connection. Much appreciated.

Kind regards Sam

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.