我已经启用mod_status我自己在 Windows 10 开发环境中使用 Apache/2.4.6 时:
<Location /server-status>
SetHandler server-status
Require host localhost
Require host example
Require host example.com
Require ip 127.0.0.1
</Location>
(example
和example.com
代表我的 Windows Active Directory 主机名。)我还使用基于名称的虚拟主机,并且我有一个大致如下所示的默认主机:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "C:/Sites/Default/htdocs"
FallBackResource /index.php
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
<Directory "C:/Sites/Default/htdocs">
Require all granted
AllowOverride All
Options -Indexes
</Directory>
</VirtualHost>
... 并且运行正常:任何未明确配置的主机名或 IP 地址都会显示我的 PHP 驱动的网站不存在错误页面,包括http://localhost/
。
我可以通过任何托管站点或 IP 地址成功访问服务器信息:
http://some.other.site.example.org/server-status
http://127.0.0.1/server-status
但是,使用localhost
主机名会触发 403 Forbidden 状态代码:
http://localhost/server-status
AH01753: access check of 'localhost' to /server-status failed, reason: unable to get the remote host name
AH01753: access check of 'example' to /server-status failed, reason: unable to get the remote host name
AH01753: access check of 'example.com' to /server-status failed, reason: unable to get the remote host name
AH01630: client denied by server configuration: C:/Sites/Default/htdocs/server-status
我尝试localhost
从ServerName
我的默认虚拟主机的指令中删除,但仍然得到禁止。
什么原因导致localhost
异常?
答案1
答案2
localhost
正在解析为 IPv6 地址,所以我需要添加以下内容:
Require ip ::1