简体   繁体   English

具有虚拟主机的Apache 2.4 mod_status配置获取禁止错误

[英]Apache 2.4 mod_status configuration with virtual hosts Getting Forbidden error

I am trying to get mod_status set up on my apache 2.4 server. 我正在尝试在我的Apache 2.4服务器上设置mod_status。 I have trawled the net for hours but all the examples given just show the tags in the main httpd.conf file, not how to place the directives into a virtual host setup. 我已经拖网了几个小时,但是给出的所有示例仅显示了httpd.conf主文件中的标记,而不是如何将指令放入虚拟主机设置中。

This is my virtual host config with what I have tried. 这是我尝试过的虚拟主机配置。 When I do this and then open a local browser or a browser from my allowed ip address (my remote public address) I get a forbidden error in the browser. 当我执行此操作,然后打开本地浏览器或从允许的IP地址(我的远程公共地址)打开浏览器时,在浏览器中出现禁止的错误。

<VirtualHost *:80>
ServerName www.thevmscloud.com
ServerAlias thevmscloud.com
ServerAdmin admin@thevmscloud.com
DocumentRoot "d:/wamp/webdocs/www/"
ErrorLog "logs/www.thevmscloud.com.log"
CustomLog "logs/www.thevmscloud.com.log" common

<Location /server-status>
  SetHandler server-status
  Order deny,allow
  Deny from all
  Require host 127.0.0.1 81.133.136.16
</Location>

<Directory "d:/wamp/webdocs/www/">
  LogLevel crit
  Options Indexes FollowSymLinks Includes ExecCGI
  AllowOverride all
  Order Allow,Deny
  Allow from all
  Require all granted
</Directory>  

I have tried all manner of different combinations of settings commented in/out, location block with the virtual host block, outside it, in the httpd.conf main body and still no joy. 我已经尝试了各种形式的注释输入/输出,位置块与虚拟主机块,外部,在httpd.conf主体中的不同组合设置,但仍然没有任何乐趣。

Trouble is, I just cant find an example of this setup anywhere. 麻烦的是,我只是在任何地方都找不到此设置的示例。 Some posts say 'you might want to add this to you virtual host config' but then dont show how. 有些帖子说“您可能想将其添加到虚拟主机配置中”,但随后不显示操作方法。

Does anybody have any idea how this is to be configured so I can browse to my domain.com/server-status and see the server stats as expected? 是否有人知道如何配置它,以便我可以浏览到domain.com/server-status并按预期查看服务器统计信息?

Many thanks Mark 非常感谢马克

Change it to this: 更改为此:

<Location /server-status>
    SetHandler server-status
    Require ip 127.0.0.1
    Require ip ::1
    Require ip 81.133.136.16
</Location>
  • Don't use require "host" if you don't need it because it will try to resolve it (especially for localhost) 如果不需要,请不要使用require“ host”,因为它将尝试解决它(尤其是本地主机)
  • Check the error logs also. 还要检查错误日志。
  • The ::1 is localhost for IPv6, you probably need it. :: 1是IPv6的本地主机,您可能需要它。

to access the server status by the name of the virtual host, and not by localhost/127.0.0.1 , please see my configuration: 要通过虚拟主机名而不是localhost / 127.0.0.1访问服务器状态,请参阅我的配置:

<IfModule mod_status.c>                                                         
<Location /server-status>                                                       
    SetHandler server-status                                                    
    Order deny,allow                                                            
    Allow from 127.0.0.1                                                        
    Allow from ::1                                                              
</Location>                                                                     
</IfModule>                                                                     

Allow from addresses the location of the client being on the same host, and not the address by which you are calling the server, given that different virtual boxes with different server addresses share the same localhost computer. 考虑到具有不同服务器地址的不同虚拟盒共享同一台本地计算机,因此from地址允许客户端位于同一主机上的位置,而不是调用服务器的地址。

since i have only one virtual box, i don't know yet whether the returned data comes split per different virtual boxes. 因为我只有一个虚拟盒子,所以我还不知道返回的数据是否按不同的虚拟盒子分开。 if you know it please edit this post or leave a comment. 如果您知道,请编辑此帖子或发表评论。

please note, that trying to access http(s)://hostname/server-status from other address failed with status 403 and the log showed the misterious: AH01797: client denied by server configuration . 请注意,尝试从其他地址访问http(s://:// hostname / server-status)失败,状态为403,日志显示错误信息: AH01797:服务器配置拒绝了客户端 in the end, i couldn't access the status from outside, even when i let Allow from all , but it wasn't that important to me. 最后,即使我允许所有人允许 ,我也无法从外部访问状态,但这对我而言并不那么重要。

hope that helps 希望能有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM