I have an ubuntu 16 server running apache 2.4. The hostname for this server is an ugly organization-mandated code which means nothing to our end users, so I've created descriptive CNAMES for the three sites this server is hosting, and configured the virtual hosts with those CNAMES. I configured the 000-default.conf
file for the ugly hostname, with a Require all denied
for the empty /var/www/html
directory.
The output from apachectl -S (redacted) is below:
# apachectl -S
VirtualHost configuration:
*:443 is a NameVirtualHost
default server UGLYNAME.domain.org (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
port 443 namevhost UGLYNAME.domain.org (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
port 443 namevhost VHOST1.domain.org (/etc/apache2/sites-enabled/VHOST1-premove-le-ssl.conf:2)
port 443 namevhost VHOST2.domain.org (/etc/apache2/sites-enabled/VHOST2-le-ssl.conf:2)
port 443 namevhost VHOST3.domain.org (/etc/apache2/sites-enabled/VHOST3-le-ssl.conf:2)
*:80 is a NameVirtualHost
default server UGLYNAME.domain.org (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost UGLYNAME.domain.org (/etc/apache2/sites-enabled/000-default.conf:1)
port 80 namevhost VHOST1.domain.org (/etc/apache2/sites-enabled/VHOST1.conf:1)
port 80 namevhost VHOST2.domain.org (/etc/apache2/sites-enabled/VHOST2.conf:1)
port 80 namevhost VHOST3.domain.org (/etc/apache2/sites-enabled/VHOST3.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex proxy: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
This has been working perfectly, so our organization has decided it's unacceptable. ;)
We are not allowed to have a website return a 403 or 404 error. I could set up a redirect to send requests for the ugly hostname to one of the virtual hosts. But what I'd really like to do is have Apache not respond at all to any requests to the hostname. Is that possible?