简体   繁体   中英

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. 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.

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.

<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.

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?

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)
  • Check the error logs also.
  • The ::1 is localhost for IPv6, you probably need it.

to access the server status by the name of the virtual host, and not by localhost/127.0.0.1 , please see my configuration:

<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.

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 . 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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