Skip to main content
ApacheCentOS

Configuring server status and information to be veiwed remotely

By April 12, 2013No Comments

Having built our minimal Apache web server we will now start adding to it to gain more understanding of the server, its modules and what they can provide. In this tutorial we are going to take a look at how we can use the shared Apache modules: mod_info and mod_status, so we can view server information and status remotely.

Of course this information should be restricted, for now we restrict access to these locations to a single internal IP address. Do remember you do not have to load these modules and choose carefully what you do load.

As we start to grow the httpd.conf we may choose to split the file into segments and use the Include directive to read in other files as needed. Firstly, we will create a modules.conf file in the server root and conf.d directory, in out case /etc/httpd/conf.d. We will then delete lines that start withLoadModule from the httpd.conf and add those lines to the modules.conf file. To make sure they are still loaded correctly when the Apache web server start we will add the line:

Include conf.d/modules.conf

We add two additional modules to support the server-info and server-status that we require:

/etc/httpd/conf.d/modules.conf

		LoadModule authz_host_module modules/mod_authz_host.so
		LoadModule dir_module modules/mod_dir.so
		LoadModule info_module modules/mod_info.so
		LoadModule status_module module/mod_status.so

To use these modules we must add some Location directives to the httpd.conf file. One for server-status and the other for server-info. We will restrict access to these locations to a single IP address in this example.

/etc/httpd/conf/httpd.conf

		Listen 0.0.0.0:80
		User apache
		Group apache
		ServerName www.example.com
		ErrorLog /var/log/httpd/error.log
		Include conf.d/modules.conf
		DirectoryIndex index.html
		DocumentRoot /var/www/html
		<Directory /var/www/html>
        	AllowOverride None
        	Order allow,deny
        	allow from 192.168.0.0/24
		</Directory>
		<Location /server-status>
		SetHandler server-status
		Order allow,deny
		Allow 192.168.0.199
		</Location>
		<Location /server-info>
		SetHandler server-info
		Order allow,deny
		Allow 192.168.0.199
		</Location>