3

I have got VPS (using CentOS 7 as my OS) and now I am configuring Munin (monitoring software). I ran into a little problem with Apache monitoring.

Now I have got this cfg in my httpd.conf and everything works fine:

<Location /server-status>
    SetHandler server-status
    Order deny,allow
    Deny from all
    Allow from localhost
</Location>

Terminal munin:

munin-node-configure --suggest | grep apache
apache_accesses            | yes  | yes                                    
apache_processes           | yes  | yes                                    
apache_volume              | yes  | yes 

But with this settings is /server-status available via all domain in the server:

example.com/server-status
example.net/server-status
192.0.2.1/example-status

I want to achieve something like this:

example.com/server-status  ---> ERROR 404
example.net/server-status ---> ERROR 404
192.0.2.1/example-status     ---> OK

So when I move the cfg from httpd.conf to my vhost default file, which now looks:

<VirtualHost _default_:80>
    DocumentRoot /var/www/server
    ErrorLog /var/log/www/server_error.log
    CustomLog /var/log/www/server_requests.log combined
</VirtualHost>

And after update:

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

Munin then stop monitor the apache service and will say:

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: server dont have host name (I mean domain), I am using server IP as his hostname now

Can you help me achieve the required setting?

  • access the server how you would access the default "domain" you are hosting via default might already do the trick. – Dennis Nolte Apr 22 '15 at 11:19
  • yes, when I move setting from httpd.conf to vhost file for default then I can access /server-status only via 1.2.3.4, but Munin show empty graphs and the error with apache server-status not found. check if mod_status is enabled – pes502 Apr 22 '15 at 11:30
1

I think you could get away with creating a vhost with the ServerName you want. The ServerName in a named-based virtual host setup maps to whatever your browser/HTTP client puts into the Host header field.

So this should work:

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

The Apache docs (https://httpd.apache.org/docs/current/mod/core.html#servername) specify you can use an IP as ServerName, and explain how ServerName works as follows:

If you are using name-based virtual hosts, the ServerName inside a section specifies what hostname must appear in the request's Host: header to match this virtual host.

  • +1 With httpd-2.2 remember also to NameVirtualHost *:80. Put this as the first VirtualHost *:80 so it would match also older HTTP/1.0 browsers. – kubanczyk Mar 24 '18 at 14:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.