Apache VirtualHost错误:主机名无效

以前对于我来说,设置一个VirtualHost来testing一个新的php web应用程序非常简单,对于这个http.conf来说:

NameVirtualHost *:80 <VirtualHost *:80> DocumentRoot /opt/webgrind/www ServerName webgrind </VirtualHost> <VirtualHost *:80> DocumentRoot /opt/opencart/www ServerName opencart </VirtualHost> 

我只需要重新启动服务并访问: http://webgrind/http://opencart/ (不需要更改/etc/hosts任何内容)

但是在服务器(CentOS 6)和现在的error.log改变了一些东西:

 [error] avahi_entry_group_add_service_strlst("opencart") failed: Invalid host name [error] avahi_entry_group_add_service_strlst("webgrind") failed: Invalid host name 

而当访问http://webgrind/我得到一个页面的行错误。 有任何想法吗?

服务器版本:Apache / 2.2.15(Unix)服务器内置:Dec 8 2011 18:10:49

由于这个问题是search“AH02415:[strict]无效主机名”时出现的第一个问题,我将添加一个答案来logging我今天浪费的时间,因为我的开发机器中的大多数虚拟主机停止工作(例如shop_one名.web)。

我有Apache更新到版本2.4.16-18.1,显然HttpProtocolOptions现在默认为Strict ,从而拒绝我的本地主机名称中有'_'(下划线)(可能是那些OP)。

我知道他们不是正确的主机名,但对于本地/个人使用从来没有伤害任何人,所以我加了一行:

 HttpProtocolOptions Unsafe 

到我的默认server.conf和生活回到了以前。 也可以看看:

https://httpd.apache.org/security/vulnerabilities_24.html

https://unix.stackexchange.com/questions/340013/why-am-i-getting-400-bad-request/341306

在apache中configuration虚拟主机并不会使服务器上的名称parsing服务知道它,所以您必须更新/ etc / hosts或执行如下操作:

curl -H 'Host: webgrind' 127.0.0.1

覆盖默认行为。