Nagios apache web configuration

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
nagiosuser22
Posts: 7
Joined: Tue Feb 24, 2015 7:35 pm

Nagios apache web configuration

Post by nagiosuser22 »

Today I installed nagios core version 4.0.8 on a RHEL 6 machine. I followed the installation instructions at http://nagios.sourceforge.net/docs/nagi ... edora.html. However, when I try to access the website at http://localhost/nagios, I get the following error message:

You don't have permission to access /nagios/ on this server.

I investigated the issue and the file /etc/httpd/conf.d/nagios.conf contains:

# 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
</Directory>

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options None
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
</Directory>

If I change the Options line under the directory entry "/usr/local/nagios/share" to:
Options All

and run "service httpd restart", then I can access the website at http://localhost/nagios. However, the "Service Detail" navbar link mentioned at http://nagios.sourceforge.net/docs/nagi ... edora.html is missing. I just see a listing of files as seen in the attached screen shot. What am I doing wrong that I don't see the "Service Detail" navbar? What value should I have for the /nagios options line?

Thank you,
Peter
Attachments
Screen shot of localhost/nagios with &quot;Options All&quot; in nagios httpd.conf file
Screen shot of localhost/nagios with "Options All" in nagios httpd.conf file
User avatar
rhassing
Posts: 416
Joined: Sat Oct 05, 2013 10:29 pm
Location: Netherlands

Re: Nagios apache web configuration

Post by rhassing »

Does the following file exist;

Code: Select all

 /usr/local/nagios/etc/htpasswd.users
Does it contain a user (nagiosadmin by default)?
Rob Hassing
Image
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios apache web configuration

Post by jdalrymple »

From step 5 on the URL you used:
Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you'll need it later.


htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Looks like you might have just missed that step.
nagiosuser22
Posts: 7
Joined: Tue Feb 24, 2015 7:35 pm

Re: Nagios apache web configuration

Post by nagiosuser22 »

Thank you for the responses. However, the file /usr/local/nagios/etc/htpasswd.users did exist. Also, I think I had already run the following command before:

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

Anyway, I ran this command again and restarted the apache web service with the command "service httpd restart". After doing that I still get the following message when trying to navigate to localhost/nagios

You don't have permission to access /nagios/ on this server.

If I change the following in /etc/httpd/conf.d/nagios.conf:

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options None
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
</Directory>

to:

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options All
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
</Directory>

Then I get the above screenshot which shows the files under /nagios with no "Service Detail" navbar.

What am I still doing wrong? Could there be something wrong in the Apache config file /etc/httpd/conf/httpd.conf? Could I have an option in there that is not set correctly? I have attached the apache main config file (/etc/httpd/conf/httpd.conf) and the Nagios Apache config file (/etc/httpd/conf.d/nagios.conf).
Attachments
nagios.conf
Nagios Apache config file
(982 Bytes) Downloaded 884 times
httpd.conf
Apache config file
(33.61 KiB) Downloaded 885 times
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios apache web configuration

Post by jdalrymple »

Code: Select all

Options None
is proper

Code: Select all

Options All
is pretty bad for security:
http://httpd.apache.org/docs/2.2/mod/core.html#options

Can you tail your log access log when you're trying to load the Nagios Core home and show us the pertinent output?

Code: Select all

tail -f /etc/httpd/logs/access_log
nagiosuser22
Posts: 7
Joined: Tue Feb 24, 2015 7:35 pm

Re: Nagios apache web configuration

Post by nagiosuser22 »

OK, I changed the settings in /etc/httpd/conf.d/nagios.conf for the nagios share back to:

Alias /nagios "/usr/local/nagios/share"

<Directory "/usr/local/nagios/share">
# SSLRequireSSL
Options None
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
</Directory>

Here is what is logged to /etc/httpd/logs/access_log when I try to access localhost/nagios:

::1 - nagiosadmin [25/Feb/2015:11:02:30 -0600] "GET /nagios/ HTTP/1.1" 403 285 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20131023 Firefox/17.0"

Also, the following is logged to /etc/httpd/log/error_log:

[Wed Feb 25 11:02:30 2015] [error] [client ::1] Directory index forbidden by Options directive: /usr/local/nagios/share/

Thank you,
Peter
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios apache web configuration

Post by jdalrymple »

Please post the results of

Code: Select all

grep -Ri directoryindex /etc/httpd/*
nagiosuser22
Posts: 7
Joined: Tue Feb 24, 2015 7:35 pm

Re: Nagios apache web configuration

Post by nagiosuser22 »

# grep -Ri directoryindex /etc/httpd/*
/etc/httpd/conf/httpd.conf:# DirectoryIndex: sets the file that Apache will serve if a directory
/etc/httpd/conf/httpd.conf:DirectoryIndex index.html index.html.var
Binary file /etc/httpd/modules/mod_dir.so matches

Thank you,
Peter
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Nagios apache web configuration

Post by jdalrymple »

Looks like your php install didn't create the DirectoryIndex.

to fix your Nagios:

Code: Select all

echo "DirectoryIndex index.php" > /usr/local/nagios/share/.htaccess; chown apache /usr/local/nagios/share/.htaccess
nagiosuser22
Posts: 7
Joined: Tue Feb 24, 2015 7:35 pm

Re: Nagios apache web configuration

Post by nagiosuser22 »

I ran those commands:

echo "DirectoryIndex index.php" > /usr/local/nagios/share/.htaccess
chown apache /usr/local/nagios/share/.htaccess

and

service httpd restart

but I still don't have access to

http://localhost/nagios/

Note that when I copied an index.html to /usr/local/nagios/share/ and then when I navigated to localhost/nagios, I saw what was on the index.html page.

Could it be that php is not enabled on my system somehow?
Locked