我有一个运行Apache2.4的ubuntu 16服务器。这个服务器的主机名是一个丑陋的组织强制代码,对我们的最终用户没有任何意义,所以我为这个服务器托管的三个站点创建了描述性CNAMES,并使用这些CNAMES配置虚拟主机。我为丑陋的主机名配置了000-default.conf文件,为空的/var/www/html目录配置了一个Require all denied。
apachectl -S (编校)的输出如下:
# 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它一直运作得很好,所以我们的组织认为这是不可接受的。;)
我们不允许网站返回403或404错误。我可以设置一个重定向,将丑陋主机名的请求发送给一个虚拟主机。但是我真正想做的是让Apache完全不响应对主机名的任何请求。这有可能吗?
发布于 2020-02-25 08:52:46
我会尝试一个301永久移动而不是,只是把它发送到你的“主”网站,不管它是什么。这比让服务器什么都不做要容易得多。另外,您忘记了只附带IP的查询,它们也会包含404。
https://serverfault.com/questions/1004413
复制相似问题