Page 1 of 2

Forbidden You don't have permission to access /nagios3/

Posted: Wed May 22, 2013 1:36 pm
by Shivaramakrishnan
Hello
I am trying to install nagios3 on debian 6 .06 and I am getting "Forbidden You don't have permission to access /nagios3/ on this server." when I try to access using browser.
I have php5 installed.Here is my default file "000-default" in sites-available dir of apache2

Code: Select all

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www/html
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/html/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined
         Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>
</VirtualHost>
-----------------------------------------------------------------------------------------------------------
In the /etc/apache2/conf.d I have a softlink to nagios3
nagios3.conf -> /etc/nagios3/apache2.conf

which has

Code: Select all

# apache configuration for nagios 3.x
# note to users of nagios 1.x and 2.x:
#   throughout this file are commented out sections which preserve
#   backwards compatibility with bookmarks/config for older nagios versios.
#   simply look for lines following "nagios 1.x:" and "nagios 2.x" comments.

ScriptAlias /cgi-bin/nagios3 /usr/lib/cgi-bin/nagios3
ScriptAlias /nagios3/cgi-bin /usr/lib/cgi-bin/nagios3
# nagios 1.x:
#ScriptAlias /cgi-bin/nagios /usr/lib/cgi-bin/nagios3
#ScriptAlias /nagios/cgi-bin /usr/lib/cgi-bin/nagios3
# nagios 2.x:
#ScriptAlias /cgi-bin/nagios2 /usr/lib/cgi-bin/nagios3
#ScriptAlias /nagios2/cgi-bin /usr/lib/cgi-bin/nagios3

# Where the stylesheets (config files) reside
Alias /nagios3/stylesheets /etc/nagios3/stylesheets
# nagios 1.x:
#Alias /nagios/stylesheets /etc/nagios3/stylesheets
# nagios 2.x:
#Alias /nagios2/stylesheets /etc/nagios3/stylesheets

# Where the HTML pages live
Alias /nagios3 /usr/share/nagios3/htdocs
# nagios 2.x:
#Alias /nagios2 /usr/share/nagios3/htdocs
# nagios 1.x:
#Alias /nagios /usr/share/nagios3/htdocs

<DirectoryMatch (/usr/share/nagios3/htdocs|/usr/lib/cgi-bin/nagios3|/etc/nagios3/stylesheets)>
    Options FollowSymLinks

    DirectoryIndex index.html

    AllowOverride AuthConfig
    Order Allow,Deny
    Allow From All

    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /etc/nagios3/htpasswd.users
    # nagios 1.x:
    #AuthUserFile /etc/nagios/htpasswd.users
    require valid-user
</DirectoryMatch>

# Enable this ScriptAlias if you want to enable the grouplist patch.
# See http://apan.sourceforge.net/download.html for more info
# It allows you to see a clickable list of all hostgroups in the
# left pane of the Nagios web interface
# XXX This is not tested for nagios 2.x use at your own peril
#ScriptAlias /nagios3/side.html /usr/lib/cgi-bin/nagios3/grouplist.cgi
# nagios 1.x:
#ScriptAlias /nagios/side.html /usr/lib/cgi-bin/nagios3/grouplist.cgi

--------------------------------------------------------------------------------------------
This is my /var/www directory
root@nagios-svr:/var/www# ls -la
total 12
drwxr-xr-x  3 root root 4096 May 22 13:15 .
drwxr-xr-x 14 root root 4096 May 21 16:53 ..
lrwxrwxrwx  1 root root   25 May 22 12:50 htdocs -> /usr/share/nagios3/htdocs
drwxr-xr-x  2 root root 4096 May 22 14:08 html
lrwxrwxrwx  1 root root   24 May 22 12:50 nagios3 -> /usr/lib/cgi-bin/nagios3
lrwxrwxrwx  1 root root   24 May 22 12:51 stylesheets -> /etc/nagios3/stylesheets
----------------------------------------------------------------------------------------------------------------------------
In html directory I have index.html file where ip address mentioned is of the nagios server

Code: Select all

<meta http-equiv="refresh" content="1; url=http://10.28.120.125/nagios3">
-----------------------------------------------------------------------------------------------------------------------------
From the apache2 error ,I see these

Code: Select all

[Wed May 22 14:19:44 2013] [error] [client 10.28.128.140] Directory index forbidden by Options directive: /usr/share/nagios3/htdocs/
[Wed May 22 14:19:48 2013] [error] [client 10.28.128.140] Directory index forbidden by Options directive: /usr/share/nagios3/htdocs/
[Wed May 22 14:20:01 2013] [error] [client 10.28.128.140] Directory index forbidden by Options directive: /usr/share/nagios3/htdocs/

I don't understand what else needs to be checked here.Can anyone please help me out asap...I need to get it in production by tomorrow.

Re: Forbidden You don't have permission to access /nagios3/

Posted: Wed May 22, 2013 1:41 pm
by abrist
Have you created an auth file? eg. /etc/nagios3/htpasswd.users

Code: Select all

htpasswd -c /etc/nagios3/htpasswd.users nagiosadmin

Re: Forbidden You don't have permission to access /nagios3/

Posted: Wed May 22, 2013 1:42 pm
by slansing
Out of curiosity, what guide are you following to install nagios on Debian??

Re: Forbidden You don't have permission to access /nagios3/

Posted: Wed May 22, 2013 1:49 pm
by Shivaramakrishnan
I forgot to mention that,I had already did that.
root@nagios-svr:/etc/nagios3#cat htpasswd.users
svaidyanathan:abcdefghijklmno

ls -lh
-rw-r----- 1 root www-data 28 May 22 13:08 htpasswd.users

I also have the user svaidyanathan added in the cgi.cfg file

I didn't follow any guide.I just installed it using apt-get install nagios3,and installed the related dependencies.
Any idea here ?Its really frustrating when the logs does not show anything else...Plz help !!!

Re: Forbidden You don't have permission to access /nagios3/

Posted: Wed May 22, 2013 3:49 pm
by abrist
Shivaramakrishnan wrote:[Wed May 22 14:19:44 2013] [error] [client 10.28.128.140] Directory index forbidden by Options directive: /usr/share/nagios3/htdocs/
Can you try browsing right to the index.php url?

Code: Select all

http://<SERVER IP>/nagios3/index.php

Re: Forbidden You don't have permission to access /nagios3/

Posted: Wed May 22, 2013 4:10 pm
by Shivaramakrishnan
No,I am not able to.Getting Http 404 not found
From apache error logs getting
[Wed May 22 17:09:49 2013] [error] [client 10.28.128.140] script '/var/www/html/index.php' not found or unable to stat


Contents of /var/www/html/index.html :
<meta http-equiv="refresh" content="1; url=http://10.28.120.125/nagios3">

I dont understand why the log is showing 'index.php' while the actual file in location /var/www/html is index.html and not 'index.php'

Re: Forbidden You don't have permission to access /nagios3/

Posted: Wed May 22, 2013 4:23 pm
by abrist

Code: Select all

http://10.28.120.125/nagios3/index.php
So this url gives you a 404?
what are the contents of the doc root? (my suspicion is that you have alias/path problems)

Code: Select all

ls -la /var/www/html/
Just FYI, this is the standard vhost configuration:

Code: Select all

ScriptAlias /nagios/cgi-bin "/usr/lib64/nagios/cgi"

<Directory "/usr/lib64/nagios/cgi">
#  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 /etc/nagios/htpasswd.users
   Require valid-user
</Directory>

Alias /nagios "/usr/share/nagios"

<Directory "/usr/share/nagios">
#  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 /etc/nagios/htpasswd.users
   Require valid-user
</Directory>
You will need to replace "/usr/lib64/nagios/cgi" with the path to your nagios cgis and replace "/usr/share/nagios" with the path to your nagios html files.

Re: Forbidden You don't have permission to access /nagios3/

Posted: Wed May 22, 2013 4:41 pm
by Shivaramakrishnan
Yes the url

Code: Select all

 http://10.28.120.125/nagios3/index.php 

gives 404 error

Contents of /var/www/html

Code: Select all

root@nagios-svr:/etc/apache2/sites-enabled# ls -la /var/www/html/
total 16
drwxr-xr-x 2 root root 4096 May 22 14:31 .
drwxr-xr-x 3 root root 4096 May 22 13:15 ..
-rw-r--r-- 1 root root   74 May 22 13:15 index.html
-rw-r--r-- 1 root root   74 Jan 12 13:15 index.html-5-22-2013
Where is this vhost defns file found?Is it the same as apache2 found under /etc/nagios3/apache2.conf ?

Re: Forbidden You don't have permission to access /nagios3/

Posted: Wed May 22, 2013 4:50 pm
by abrist
Shivaramakrishnan wrote:Where is this vhost defns file found?
These usually come with the package or source.
What is the path to:
Your nagios html files?
Your nagios cgis?

Is this apache server hosting any other websites?

Re: Forbidden You don't have permission to access /nagios3/

Posted: Thu May 23, 2013 8:52 am
by Shivaramakrishnan
Path to cgi's:

Code: Select all

root@nagios-svr:/usr/lib/cgi-bin# cd nagios3/
root@nagios-svr:/usr/lib/cgi-bin/nagios3# ls -la
total 3448
drwxr-xr-x 2 root root   4096 May 21 16:53 .
drwxr-xr-x 3 root root   4096 May 21 16:53 ..
-rwxr-xr-x 1 root root 246952 Feb  1 16:13 avail.cgi
-rwxr-xr-x 1 root root 247584 Feb  1 16:13 cmd.cgi
-rwxr-xr-x 1 root root 206376 Feb  1 16:13 config.cgi
-rwxr-xr-x 1 root root 259176 Feb  1 16:13 extinfo.cgi
-rwxr-xr-x 1 root root 214376 Feb  1 16:13 histogram.cgi
-rwxr-xr-x 1 root root 193672 Feb  1 16:13 history.cgi
-rwxr-xr-x 1 root root 189552 Feb  1 16:13 notifications.cgi
-rwxr-xr-x 1 root root 185416 Feb  1 16:13 outages.cgi
-rwxr-xr-x 1 root root 185704 Feb  1 16:13 showlog.cgi
-rwxr-xr-x 1 root root 251048 Feb  1 16:13 status.cgi
-rwxr-xr-x 1 root root 210312 Feb  1 16:13 statusmap.cgi
-rwxr-xr-x 1 root root 202472 Feb  1 16:13 statuswml.cgi
-rwxr-xr-x 1 root root 189576 Feb  1 16:13 statuswrl.cgi
-rwxr-xr-x 1 root root 210376 Feb  1 16:13 summary.cgi
-rwxr-xr-x 1 root root 201888 Feb  1 16:13 tac.cgi
-rwxr-xr-x 1 root root 218472 Feb  1 16:13 trends.cgi
Path to html:

Code: Select all

root@nagios-svr:/var/www# ls -la
total 12
drwxr-xr-x  3 root root 4096 May 22 13:15 .
drwxr-xr-x 14 root root 4096 May 21 16:53 ..
lrwxrwxrwx  1 root root   25 May 22 12:50 htdocs -> /usr/share/nagios3/htdocs
drwxr-xr-x  2 root root 4096 May 22 14:31 html
lrwxrwxrwx  1 root root   24 May 22 12:50 nagios3 -> /usr/lib/cgi-bin/nagios3
lrwxrwxrwx  1 root root   24 May 22 12:51 stylesheets -> /etc/nagios3/stylesheets
contents of html directory

Code: Select all

root@nagios-svr:/var/www/html# ls -la
total 16
drwxr-xr-x 2 root root 4096 May 22 14:31 .
drwxr-xr-x 3 root root 4096 May 22 13:15 ..
-rw-r--r-- 1 root root   74 May 22 13:15 index.html
-rw-r--r-- 1 root root  177 May 22 13:15 index.html-5-22-2013
contents of index.html:

Code: Select all

<meta http-equiv="refresh" content="1; url=http://10.28.120.125/nagios3">
First few lines in cgi.cfg under /etc/nagios3

Code: Select all

#################################################################
#
# CGI.CFG - Sample CGI Configuration File for Nagios
#
#################################################################


# MAIN CONFIGURATION FILE
# This tells the CGIs where to find your main configuration file.
# The CGIs will read the main and host config files for any other
# data they might need.

main_config_file=/etc/nagios3/nagios.cfg



# PHYSICAL HTML PATH
# This is the path where the HTML files for Nagios reside.  This
# value is used to locate the logo images needed by the statusmap
# and statuswrl CGIs.

physical_html_path=/usr/share/nagios3/htdocs



# URL HTML PATH
# This is the path portion of the URL that corresponds to the
# physical location of the Nagios HTML files (as defined above).
# This value is used by the CGIs to locate the online documentation
# and graphics.  If you access the Nagios pages with an URL like
# http://www.myhost.com/nagios, this value should be '/nagios'
# (without the quotes).

url_html_path=/nagios3

I don't have any other website hosting on this server
I see
"Forbidden
You don't have permission to access /nagios3/ on this server.
403 Forbidden"

Still getting the same error from logs:
[Thu May 23 09:56:26 2013] [error] [client 10.28.128.140] Directory index forbidden by Options directive: /usr/share/nagios3/htdocs/
Please help me out as I need to get this into production in this weekend.