此设置正在ubuntu 14.04上运行,直到最近更新(可能包中的更新/更改本身已经过时)。
<VirtualHost *:80>
ServerName "piwik.7l"
ServerAlias www.piwik.7l
</VirtualHost>
如果通过IP解决,设置现在可以正常工作,但如果通过其域(piwik.7l)浏览,则响应400 Bad Request。 400页面包含
Apache/2.4.7 (Ubuntu) Server at piwik.7l Port 80
,在将LogLevel设置为debug后,我在error.log
中看到以下消息:
[Mon May 22 15:12:33.566249 2017] [core:debug] [pid 1559] vhost.c(794): [client 192.168.1.112:38587] AH02415: [strict] Invalid host name 'piwik.7l', problem near: .7l
[Mon May 22 15:12:33.566316 2017] [core:debug] [pid 1559] vhost.c(889): [client 192.168.1.112:38587] AH00550: Client sent malformed Host header: piwik.7l
[Mon May 22 15:12:33.566326 2017] [core:debug] [pid 1559] protocol.c(1356): [client 192.168.1.112:38587] AH00569: client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /
滚动友好
[strict] Invalid host name 'piwik.7l', problem near: .7l
AH00550: Client sent malformed Host header: piwik.7l
AH00569: client sent HTTP/1.1 request without hostname (see RFC2616 section 14.23): /
我在VirtualHost / ServerName / ServerAlias块中尝试了各种IP,端口和域名使用组合,并禁用了所有其他VirtualHost定义。
听起来好像Apache会以严格的方式尝试验证域的“tld
”部分(7l
)。有什么方法可以禁用它或进一步调试它?
修改
apache2ctl -S
的相关部分:
VirtualHost configuration:
*:80 piwik.7l (/etc/apache2/sites-enabled/000-default.conf:1)
编辑2
ping piwik.7l
从网络服务器和我的机器上解析得很好。
答案 0 :(得分:2)
感谢@savedarios回答:https://serverfault.com/questions/658537/apache-virtualhost-error-invalid-host-name/841984#841984
如果发现解决方案是对我的apache2.conf的以下更改:
HttpProtocolOptions Unsafe