Request URL /server-status or 404 Page Not Found Apache HTTPD Error

»»»Request URL /server-status or 404 Page Not Found Apache HTTPD Error

In Apache web server, when an administrator wants to check the Apache server status with the command “apachectl status” or “service httpd fullstatus” at shell prompt, the following error may occur:

Not Found

The requested URL /server-status was not found on this server.

If you request the Apache status from web page by viewing http://domain_name/server-status link location, a 404 page not found error will be returned by web server to the web browser.

There are several reasons why this problem can occurred. First thing to check is to ensure that the mod_status status handler is properly setup and loaded in httpd.conf configuration file. Using APXS, the following 2 lines must exist:

LoadModule status_module /path/to/apache/modules/mod_status.so
AddModule mod_status.c

If the lines exist, the problem probably lies on virtual host declaration. As a side note, you can also check if the status handler is been activated to show more information (but will slow down a busy server) by locating the following line in httpd.conf (default to off):

ExtendedStatus On

For virtual host for server-status, ensure that the following line exists in your Apache configuration file:

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

You can change the localhost to your domain name such as .example.com (including dot in front of domain) to allow access from domain address. Else localhost restrict access doesn’t allow public access to server-status, and only command shell access locally is possible.

Note that also if you use NameVirtualHost *:80 directive, or any *:port directive to run multiple name based virtual hosts, this configuration does not allow server-status on any of the publicly accessible addresses. The reason is that the first Virtual Host in the directive is considered the “Default Virtual Host”, and any unknown entries on the NameVirtualHost space whenever user or process attempts to access port 80 on any IP address, will go to this virtual host by default. Hence the 404 page not found error is returned. Furthermore the server-status configuration cannot be placed inside of a VirtualHost directive to be read from a full domain name.

There are 2 solutions or workarounds for this scenario, either by making the server listen on an alternative port (such as port 8080), or allowing only internal or local access.

To change to another port, simply adding “Listen 8080” to the configuration, and you can access the server status from external by using http://domain:8080/server-status in any web browser.

To allow only local access for commands such as ‘apachectl status’ or ‘service httpd fullstatus’, simply switch each * to the actual IP address to work from, then accessing from localhost (127.0.0.1) will work.

For example, change from:

NameVirtualHost *:80
<VirtualHost *:80>

to

NameVirtualHost 10.0.0.3:80
<VirtualHost 10.0.0.3:80>

Once configuration file is modified correctly, restart Apache HTTPD server.

By |2017-01-26T03:22:23+00:00January 26th, 2017|Categories: Web Servers|Tags: |4 Comments

About the Author:

LK is a technology writer for Tech Journey with background of system and network administrator. He has be documenting his experiences in digital and technology world for over 15 years.Connect with LK through Tech Journey on Facebook, Twitter or Google+.