我们有一个 Apache 服务器配置,在 conf/httpd.conf 中我们有(为简洁起见,该文件的其余部分已被删除):
LoadModule status_module modules/mod_status.so
ExtendedStatus On
在 conf.d/myserver.conf 中我们有(其他部分再次删除):
Listen 8162
<VirtualHost *:8162>
<Location /server-status>
SetHandler server-status
Order allow,deny
Allow from localhost
Deny from all
</Location>
</VirtualHost>
请注意,在 httpd.conf 中,所有 Listen 指令均被注释掉,这意味着 Apache 仅监听端口 8162。<Location /server-status>
在 httpd.conf 中也被注释掉。
403
当我们尝试时,我们得到:
wget http://localhost:8162/server-status
服务器状态可以在非标准端口上运行吗?如果可以,我们还应该寻找什么才能使服务器状态可从本地主机访问?
答案1
这对我有用,当在端口 80 上使用 varnish 时,从端口 8000 为 apache 提供服务,并在端口 8001 上定义一个额外的 apache 监听
/etc/apache2/mods-enabled/status.conf
。
<IfModule mod_status.c>
#
# Allow server status reports generated by mod_status,
# with the URL of http://servername/server-status
# Uncomment and change the ".example.com" to allow
# access from other hosts.
#
Listen 8001
ExtendedStatus On
<VirtualHost *:8001>
<Location /server-status>
SetHandler server-status
Order deny,allow
Deny from all
Allow from localhost ip6-localhost
# Allow from .example.com
</Location>
</VirtualHost>
</IfModule>
你可以用 lynx 测试一下
lynx -dump http://127.0.0.1:8001/server-status
lynx 的输出看起来应该像这样:~
Apache Server Status for 127.0.0.1
Server Version: Apache/2.2.14 (Ubuntu) mod_ssl/2.2.14 OpenSSL/0.9.8k
Server Built: Nov 3 2011 03:29:23
__________________________________________________________________
Current Time: Saturday, 03-Dec-2011 12:36:05 CET
Restart Time: Friday, 02-Dec-2011 00:59:04 CET
Parent Server Generation: 22
Server uptime: 1 day 11 hours 37 minutes
Total accesses: 44550 - Total Traffic: 368.1 MB
CPU Usage: u27.53 s3.48 cu0 cs0 - .0242% CPU load
.347 requests/sec - 3010 B/second - 8.5 kB/request
2 requests currently being processed, 4 idle workers
W___._W.........................................................
--cut--