Nagios Directory Index Forbidden by Options Directive
After installing Nagios on a Raspberry Pi 2 Model B by following these installation instructions, I ran into an irritating problem. When trying to connect, I got the authentication dialog, but after that, I got an access error in my browser.
Directory index forbidden by Options directive: /usr/local/nagios/share
I searched around on Google but couldn’t find a solution. But after a lot of fiddling with Apache2, I found a solution. There’s a problem with the standard installation of the file in /etc/apache2/conf.d/nagios.conf created by make install-webconf
To make my search for the problem more manageable, I disabled authentication in /etc/apache2/conf.d/nagios.conf so one source of potential problems were eliminated. I just commented out the Auth lines. Then when I accessed http://localhost/nagios/index.php I got the error:
[error] [client 10.200.2.115] script '/usr/local/nagios/shareindex.php' not found or unable to stat
Aha! Something is missing in the name shareindex.php. It should only be index.php. In the automatically configured nagios.conf file that the make install-webconf command creates, the Alias directive for Apache2 was missing a simple “/” at the end. So all you have to do to fix the problem is to add a trailing / to the end of the path set up by the Alias.
Here’s the original Alias directive in nagios.conf
Alias /nagios/ "/usr/local/nagios/share"
All you have to do is to change it to:
Alias /nagios/ "/usr/local/nagios/share/"
Sometimes small errors can create annoying problems. There’s a lot of (wrong) answers when doing a Google search, so hopefully, this will rank enough to help someone that has this annoying, but easily solved problem, they’ll find this.
Here’s the fixed /etc/apache2/conf.d/nagios.conf for posterity.
SAMPLE CONFIG SNIPPETS FOR APACHE WEB SERVER # This file contains examples of entries that need to be incorporated into your Apache web server configuration file. Customize the paths, etc. as needed to fit your system. ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin" <directory "/usr/local/nagios/sbin"> SSLRequireSSL Options +ExecCGI AllowOverride None Order allow,deny Allow from all Order deny,allow Deny from all Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user Alias /nagios/ "/usr/local/nagios/share/" <directory "/usr/local/nagios/share"> SSLRequireSSL Options None DirectoryIndex index.php AllowOverride None Order allow,deny Allow from all Order deny,allow Deny from all Allow from 127.0.0.1 AuthName "Nagios Access" AuthType Basic AuthUserFile /usr/local/nagios/etc/htpasswd.users Require valid-user