I have a single server (single ip) running apache, an email server (smtp, imap) and bind. It serves a single domain (example.com). In bind, I have set up www.example.com, example.com, ns.example.com (for DNS) and mail.example.com which naturally all point to the same ip.
I would like to point both, www.example.com and example.com to my website, so in my apache configuration I created a virtual host with "ServerName www.example.com" and "ServerAlias example.com"
Now if somebody is accessing www.example.com or example.com in the browser they end up on my website, however also people accessing mail.example.com or ns.example.com (in the browser) end up on my website. As far as I understand reading [
httpd.apache.org ], this is due to the fact that I did not define virtual hosts for mail.example.com or ns.example.com and in that case those pages end up on the first listed virtual host (
If no matching virtual host is found, then the first listed virtual host that matches the IP address will be used.
)
I don't want people to access my website via mail.example.com or ns.example.com. Is there a way to disable the default behaviour of apache regarding un-defined virtual hosts? Or should I create a virtual host for mail.example.com (ns.example.com) and serve an error page or an empty page. In that case, what would be a good content for an error page?