Like most servers, Apache allows you to capture details about its performance and status. These metrics are not published by default however and can be tricky to configure securely, especially in an environment using virtual hosts. This article describes how to configure Apache2 to enable its server-status statistics which can be viewed directly via web browser or collected by monitoring tools such as FiveRuns Manage. Additional metrics are published by enabling ExtendedStatus which we will also enable.
In its simplest implementation, there are just a few steps to enable Apache’s mod_status. In the Apache2 configuration file, (often: /etc/apache2/apache2.conf for Apache2 and /etc/httpd/conf/http.conf for Apache v.1.x) this is enabled by adding or uncommenting the following lines:
LoadModule status_module libexec/apache2/mod_status.so
ExtendedStatus On
<Location /server-status>
SetHandler server-status
order deny,allow
deny from all
allow from 127.0.0.1
</Location>
The above edits and a restart of Apache will publish the status metrics to clients on the local system. As in the Apache.org example, security can be lowered to allow remote clients access the server statistics. Since that can be a security concern and because monitoring tools can be installed locally, our examples restrict access to the local web server.
One challenge we often encounter is Apache environments using virtual hosts. The <Location /server-status> directive needs to either appear in the parent apache.conf/http.conf file or in the virtual host that is loaded first. When multiple .conf files are loaded via the Include directive, it is done alphabetically, so consider this when inserting the server-status Location block.
Alternately, you could dedicate a virtual host to serve the status information and bypass the load ordering issue above. The example below details a NameVirtualHost configuration utilizing the localhost hostname. A similar approach could be used to dedicate a vhost using IP-based Virtual Hosts and 127.0.0.1.
<VirtualHost *:80>
ServerName localhost
ServerAlias 127.0.0.1
DocumentRoot /var/www/
<Location />
order deny,allow
deny from all
allow from 127.0.0.1
</Location>
<Location /server-status>
SetHandler server-status
order deny,allow
deny from all
allow from 127.0.0.1
</Location>
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>















Continued Discussion
No comments have been added yet.