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

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.
sachinambardekar
Posts: 23
Joined: Sat Jan 07, 2017 7:21 pm

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

Post by sachinambardekar »

Hello Support,

I have installed the nagios-4.2.4 and nagios-plugins-2.1.4 with no error. Issue is when I try to access the Nagios using web interface I am getting below error. This issue is happening when I use servername.domain/nagios and IP address/nagios, however, I can login successfully with localhost/nagios url

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

Below is the message from /var/log/httpd/error_log

Code: Select all

[Thu Jan 05 04:58:43 2017] [error] [client 192.168.1.13] Directory index forbidden by Options directive: /usr/local/nagios/share/
[Thu Jan 05 05:01:52 2017] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/
[Thu Jan 05 05:06:52 2017] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/
[Thu Jan 05 05:11:52 2017] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/
[Thu Jan 05 05:16:52 2017] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/
[Thu Jan 05 05:21:52 2017] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/
[Thu Jan 05 05:24:59 2017] [error] [client 192.168.1.13] Directory index forbidden by Options directive: /usr/local/nagios/share/
[Thu Jan 05 05:24:59 2017] [error] [client 192.168.1.13] File does not exist: /var/www/html/favicon.ico, referer: http://ambari.localdomain/nagios/
[Thu Jan 05 05:26:52 2017] [error] [client 127.0.0.1] Directory index forbidden by Options directive: /var/www/html/
I can see that php rpm is installed in the system
[root@~etc]# rpm -qa php
php-5.3.3-48.el6_8.x86_64

index.php entry is also included in php.conf file located under /etc/httpd/conf.d

Code: Select all

[root@~conf.d]# pwd
/etc/httpd/conf.d
[root@~conf.d]# cat php.conf
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>

#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php

#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php

#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
Please advise.

Thank you,
Last edited by dwhitfield on Wed Jan 18, 2017 5:25 pm, edited 1 time in total.
Reason: code blocks FTW
dwhitfield
Former Nagios Staff
Posts: 4583
Joined: Wed Sep 21, 2016 10:29 am
Location: NoLo, Minneapolis, MN
Contact:

Re: You don't have permission to access /nagios/ on this ser

Post by dwhitfield »

What version of Core are you using? Was it compiled from source or installed from distro repos? On what OS/version is nagios running? cat /etc/*-release may be of use.

It's likely you missed a step in the compile instructions, or if you are running a distro we don't have instructions for, maybe there is a different dependency. In the past, equivalents to apache2-mod_php5 have been ones that have not gotten pulled in.

One last question: what instructions did you use?
sachinambardekar
Posts: 23
Joined: Sat Jan 07, 2017 7:21 pm

Re: You don't have permission to access /nagios/ on this ser

Post by sachinambardekar »

Below are the steps followed:

Nagios core version is 4.2.4 and nagios-plugins is on 2.1.4

OS is Oracle Linux 6.8

Steps followed:

1) Download Nagios Core from https://www.nagios.org/downloads/nagios-4.2.4.tar
2) Download Nagios plugins from https://www.nagios.org/downloads/nagios ... -2.1.4.tar
3) Install pre-requisite rpm using yum utility httpd,php,gcc,glibc,glibc-common,gd,gd-devel
4) create nagios OS user and nagcmd group and attach group to the user
5) Untar the software to the server under /root/repos directory
6) Change the directory to /root/repos/nagios-4.2.4 directory and start configuring nagios
• [root@ambari nagios-4.2.4]# ./configure --with-command-group=nagcmd

*** Configuration summary for nagios 4.2.4 12-07-2016 ***:

General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Install ${includedir}: /usr/local/nagios/include/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu
IOBroker Method: epoll

Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute


Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
Compile the nagios source code

• [root@ambari nagios-4.2.4]# make all

• [root@ambari nagios-4.2.4]# make install

• [root@ambari nagios-4.2.4]# make install-init
/usr/bin/install -c -m 755 -d -o root -g root /etc/rc.d/init.d
/usr/bin/install -c -m 755 -o root -g root daemon-init /etc/rc.d/init.d/nagios

*** Init script installed ***

• [root@ambari nagios-4.2.4]# make install-config
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/etc/objects
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/nagios.cfg /usr/local/nagios/etc/nagios.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/cgi.cfg /usr/local/nagios/etc/cgi.cfg
/usr/bin/install -c -b -m 660 -o nagios -g nagios sample-config/resource.cfg /usr/local/nagios/etc/resource.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/templates.cfg /usr/local/nagios/etc/objects/templates.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/commands.cfg /usr/local/nagios/etc/objects/commands.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/contacts.cfg /usr/local/nagios/etc/objects/contacts.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/timeperiods.cfg /usr/local/nagios/etc/objects/timeperiods.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/localhost.cfg /usr/local/nagios/etc/objects/localhost.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/windows.cfg /usr/local/nagios/etc/objects/windows.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/printer.cfg /usr/local/nagios/etc/objects/printer.cfg
/usr/bin/install -c -b -m 664 -o nagios -g nagios sample-config/template-object/switch.cfg /usr/local/nagios/etc/objects/switch.cfg

*** Config files installed ***

Remember, these are *SAMPLE* config files. You'll need to read
the documentation for more information on how to actually define
services, hosts, etc. to fit your particular needs.

• [root@ambari nagios-4.2.4]# make install-commandmode
/usr/bin/install -c -m 775 -o nagios -g nagcmd -d /usr/local/nagios/var/rw
chmod g+s /usr/local/nagios/var/rw

*** External command directory configured ***

7) Edit the /usr/local/nagios/etc/objects/contact.cfg config file and change the email address associated with the nagiosadmin contact definition to the address for receiving alerts.
8) Install the nagios web config file in the Apache conf.d directory
• [root@ambari nagios-4.2.4]# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf
if [ 0 -eq 1 ]; then \
ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/nagios.conf; \
fi

*** Nagios/Apache conf file installed ***

9) Create a nagisoadmin account for logging into the nagios web interface.

• [root@ambari nagios-4.2.4]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
10) Restart Apache to make the new settings take effect

• [root@ambari nagios-4.2.4]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
11) Install nagios plugin. Change the directory to /root/repos/nagios-plugins-2.1.4

• [root@ambari nagios-plugins-2.1.4]# pwd
/root/repos/nagios-plugins-2.1.4
12) Compile and install the plugin

• [root@ambari nagios-plugins-2.1.4]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios

• [root@ambari nagios-plugins-2.1.4]# make

• [root@ambari nagios-plugins-2.1.4]# make intall

• [root@ambari nagios-plugins-2.1.4]# chkconfig --add nagios

• [root@ambari nagios-plugins-2.1.4]# chkconfig nagios on
13) Verify the sample Nagios configuration file

• [root@ambari nagios-plugins-2.1.4]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Nagios Core 4.2.4
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 12-07-2016
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
Checked 8 services.
Checked 1 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check

14) Start Nagios services

• [root@ambari nagios-plugins-2.1.4]# service nagios start
Starting nagios: done.


Please advise.

Thank you,
Sachin A
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: You don't have permission to access /nagios/ on this ser

Post by rkennedy »

Please post your entire /etc/httpd/conf.d/ folder for us to look at - I suspect you're missing the Core apache configuration file. It should be something similar to this -

(centos/rhel is /etc/httpd/conf.d/* - below is Ubuntu - may vary based on your OS)

Code: Select all

root@localhost:/etc/apache2/sites-enabled# cat nagios.conf
# 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
   <IfVersion >= 2.3>
      <RequireAll>
         Require all granted
#        Require host 127.0.0.1

         AuthName "Nagios Access"
         AuthType Basic
         AuthUserFile /usr/local/nagios/etc/htpasswd.users
         Require valid-user
      </RequireAll>
   </IfVersion>
   <IfVersion < 2.3>
      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
   </IfVersion>
</Directory>

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

<Directory "/usr/local/nagios/share">
#  SSLRequireSSL
   Options None
   AllowOverride None
   <IfVersion >= 2.3>
      <RequireAll>
         Require all granted
#        Require host 127.0.0.1

         AuthName "Nagios Access"
         AuthType Basic
         AuthUserFile /usr/local/nagios/etc/htpasswd.users
         Require valid-user
      </RequireAll>
   </IfVersion>
   <IfVersion < 2.3>
      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
   </IfVersion>
</Directory>

Former Nagios Employee
sachinambardekar
Posts: 23
Joined: Sat Jan 07, 2017 7:21 pm

Re: You don't have permission to access /nagios/ on this ser

Post by sachinambardekar »

uploaded /etc/httpd/conf.d folder.

Please advise.

Thank you,
Sachin A
Attachments
conf.zip
(2.04 KiB) Downloaded 443 times
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: You don't have permission to access /nagios/ on this ser

Post by rkennedy »

It looks like nagios.conf is present - please run service httpd restart, then attempt to access the Core GUI.

If it fails, then please post the full output of the following so we can look at your apache logs - tail -n100 /var/log/httpd/*_log
Former Nagios Employee
sachinambardekar
Posts: 23
Joined: Sat Jan 07, 2017 7:21 pm

Re: You don't have permission to access /nagios/ on this ser

Post by sachinambardekar »

Support,

Uploaded error screenshots and httpd logs

Please advise,

Thank you,
Sachin A
Attachments
httpd_log.zip
httpd logs
(84.48 KiB) Downloaded 275 times
nagios UI Error.docx
Nagios UI Error
(841.97 KiB) Downloaded 290 times
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: You don't have permission to access /nagios/ on this ser

Post by rkennedy »

I believe the issue is here -

Code: Select all

 Directory index forbidden by Options directive
You'll want to consult whomever setup apache, or take a look at this article to see if it helps - http://stackoverflow.com/questions/5301 ... -directive

Our install expects a clean version of apache, but it looks like you have other things running on this machine as well -

Code: Select all

192.168.1.79 - - [01/Jan/2017:03:46:07 -0800] "GET /repos/HDP/centos6/2.x/updates/2.3.0.0/repodata/repomd.xml HTTP/1.1" 200 2997 "-" "urlgrabber/3.9.1 yum/3.2.29"
192.168.1.79 - - [01/Jan/2017:03:46:07 -0800] "GET /repos/HDP-UTILS-1.1.0.20/repos/centos6/repodata/repomd.xml HTTP/1.1" 200 2992 "-" "urlgrabber/3.9.1 yum/3.2.29"
Former Nagios Employee
sachinambardekar
Posts: 23
Joined: Sat Jan 07, 2017 7:21 pm

Re: You don't have permission to access /nagios/ on this ser

Post by sachinambardekar »

On the server I am running other softwares which require httpd services. Does it mean that Nagios require a dedicated server?

I installed httpd using yum.
yum install httpd.

Please advise

Thank you,
Sachin A
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: You don't have permission to access /nagios/ on this ser

Post by rkennedy »

sachinambardekar wrote:On the server I am running other softwares which require httpd services. Does it mean that Nagios require a dedicated server?
No, but you'll need to configure Apache to work with your multiple different applications. I pointed out where the issue is in my previous configuration - I would consult whomever manages the machine to modify your apache settings accordingly.
Former Nagios Employee
Locked