我有VPS(使用CentOS 7作为我的操作系统),现在我正在configurationMunin (监控软件)。 我遇到了Apache监控的一个小问题。
现在我已经得到了这个cfg在我的httpd.conf ,一切工作正常:
<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from localhost </Location>
terminal慕尼黑:
munin-node-configure --suggest | grep apache apache_accesses | yes | yes apache_processes | yes | yes apache_volume | yes | yes
但是,通过/server-status所有域,可以通过此设置获得/server-status :
example.com/server-status example.net/server-status 192.0.2.1/example-status
我想实现这样的事情:
example.com/server-status ---> ERROR 404 example.net/server-status ---> ERROR 404 192.0.2.1/example-status ---> OK
所以当我将httpd.conf中的cfg移动到我的虚拟主机默认文件 ,现在看起来如下:
<VirtualHost _default_:80> DocumentRoot /var/www/server ErrorLog /var/log/www/server_error.log CustomLog /var/log/www/server_requests.log combined </VirtualHost>
更新后:
<VirtualHost _default_:80> DocumentRoot /var/www/server ErrorLog /var/log/www/server_error.log CustomLog /var/log/www/server_requests.log combined <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from localhost </Location> </VirtualHost>
然后,穆宁停止监控Apache服务,并会说:
apache_accesses | yes | no [apache server-status not found. check if mod_status is enabled] apache_processes | yes | no [apache server-status not found. check if mod_status is enabled] apache_volume | yes | no [apache server-status not found. check if mod_status is enabled]
PS:服务器没有主机名(我的意思是域),我现在使用服务器IP作为他的主机名
你能帮我实现所需的设置吗?
我想你可以逃脱用你想要的ServerName创build一个虚拟主机。 基于命名的虚拟主机设置中的ServerName映射到您的浏览器/ HTTP客户端放置到Host头字段中的任何地方。
所以这应该工作:
<VirtualHost *:80> ServerName 192.168.1.2 DocumentRoot /var/www/server ErrorLog /var/log/www/server_error.log CustomLog /var/log/www/server_requests.log combined <Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from localhost </Location> </VirtualHost>
Apache文档( https://httpd.apache.org/docs/current/mod/core.html#servername )指定您可以使用IP作为ServerName,并解释ServerName如何工作,如下所示:
如果您使用的是基于名称的虚拟主机,则部分内的ServerName将指定在请求的Host:头中必须出现的主机名才能与此虚拟主机相匹配。