在我的apache2服务器,我访问/server-status来检查我的networking服务器的当前状态。 我发现mods-available / status.conf包含负责显示状态的片段。
<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from localhost ip6-localhost </Location>
我的问题是我怎样才能使它不仅本地主机,而且还有authentication的远程主机?
要允许其他主机,你可以更新行:
Allow from localhost ip6-localhost
读书:
Allow from localhost ip6-localhost 1.2.3.4 1.2.3
对于身份validation部分,您添加一个块,如:
AuthType Basic AuthName "Restricted Files" # (Following line optional) AuthBasicProvider file AuthUserFile /usr/local/apache/passwd/passwords Require user rbowen
passwords文件需要使用htpasswd工具创build。 看看这个页面的更多细节。
在<Location /server-status>节中,同时包含Allow from localhost和authentication指令。 关键是使用Satisfy Any来指定来自本地主机的请求可以绕过authentication。
编辑:明确的例子,按要求(它只是结合了目前为止所有人都说的):
<Location /server-status> SetHandler server-status Order deny,allow Deny from all Satisfy Any Allow from localhost ip6-localhost AuthType basic AuthName "Apache status" AuthUserFile /etc/apache2/passwd-server-status Require valid-user </Location>
你可以使用类似的东西:
<Location /server-status> SetHandler server-status AuthType basic AuthName "Apache status" AuthUserFile /etc/apache2/passwd-server-status Require valid-user </Location>
另外,不要忘了用下面的命令来创build密码文件和帐户(用你喜欢的任何用户名replace用户名):
htpasswd -c /etc/apache2/passwd-server-status username
什么是apache具有服务器状态处理程序configuration的风险。我可以在我的web服务器中看到此文件SetHandler服务器状态AuthType基本AuthName“Apache状态”AuthUserFile / etc / apache2 / passwd服务器状态要求有效用户