Solved

Directory index forbidden

Posted on 2011-09-04
17
584 Views
Last Modified: 2013-12-25
Hi,

I've been trying to figure out why this error comes up when trying to access my nagios installation on OpenBSD.

Directory index forbidden by rule: /nagios/
 Thats the error i get when I try to access http://servername/nagios/

Has anyone been able to resolve this error.
I followed the instructions from http://www.kernel-panic.it/openbsd/nagios/ and have re-looked at the cofigs i did and i just can't figure out what's wrong.

Waisiki
0
Comment
Question by:itc_sysadmin
  • 9
  • 8
17 Comments
 
LVL 13

Expert Comment

by:LinuxGuru
ID: 36480487
Hi,

Could you please paste the output of apache error log? This seems to a permission / ownership issue. We need the exact error in apache logs to troubleshoot the issue.

You can use the following command to monitor apache log.

tail -f /usr/local/apache/log/error_log

The location to error_log may vary.

Cheers !!!
0
 
LVL 13

Expert Comment

by:LinuxGuru
ID: 36480493
Also please place the following code in your .htaccess file and let me know the results.

Options Indexes

0
 

Author Comment

by:itc_sysadmin
ID: 36481820
Here's the apache error_log

# tail -f /var/www/logs/error_log
[Mon Sep  5 04:30:54 2011] [client 10.2.40.56] Directory index forbidden by rule: /nagios/
[Mon Sep  5 04:30:54 2011] [client 10.2.40.56] Directory index forbidden by rule: /nagios/
[Mon Sep  5 04:30:55 2011] [client 10.2.40.56] Directory index forbidden by rule: /nagios/
[Mon Sep  5 04:30:55 2011] [client 10.2.40.56] Directory index forbidden by rule: /nagios/
[Mon Sep  5 05:36:56 2011] [notice] caught SIGTERM, shutting down
[Mon Sep  5 05:58:33 2011] [notice] Initializing etag from /var/www/logs/etag-state
[Mon Sep  5 05:58:34 2011] [notice] chrooted in /var/www
[Mon Sep  5 05:58:34 2011] [notice] changed to uid 67, gid 67
[Mon Sep  5 05:58:34 2011] [notice] Apache configured -- resuming normal operations
[Mon Sep  5 05:58:34 2011] [notice] Accept mutex: sysvsem (Default: sysvsem)
[Mon Sep  5 06:16:23 2011] [client 10.2.40.56] Directory index forbidden by rule: /nagios/
[Mon Sep  5 06:16:27 2011] [client 10.2.40.56] Directory index forbidden by rule: /nagios/
[Mon Sep  5 06:16:28 2011] [client 10.2.40.56] Directory index forbidden by rule: /nagios/
[Mon Sep  5 06:16:28 2011] [client 10.2.40.56] Directory index forbidden by rule: /nagios/
[Mon Sep  5 06:16:29 2011] [client 10.2.40.56] Directory index forbidden by rule: /nagios/
0
 

Author Comment

by:itc_sysadmin
ID: 36482423
> Also please place the following code in your .htaccess file and let me know the results.

> Options Indexes

I've been searching for the .htaccess file and I can't find it in any of the folders.
0
 

Author Comment

by:itc_sysadmin
ID: 36482450
This is the configuration for apache.

ScriptAlias /cgi-bin/nagios "/var/www/cgi-bin/nagios"

<Directory "/var/www/cgi-bin/nagios">
    SSLRequireSSL

    Options ExecCGI

    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /users/nagios.passwd
    Require valid-user

    Order deny,allow
    Deny from all
    # Authorized clients
    Allow from 127.0.0.1 172.16.0.13
</Directory>

Alias /nagios "/var/www/nagios"

<Directory "/var/www/nagios">
    SSLRequireSSL

    Options None
    AllowOverride None

    AuthName "Nagios Access"
    AuthType Basic
    AuthUserFile /users/nagios.passwd
    Require valid-user

    Order deny,allow
    Deny from all
    # Authorized clients
    Allow from 127.0.0.1 172.16.0.13
</Directory>
0
 
LVL 13

Expert Comment

by:LinuxGuru
ID: 36484387
Hi,

Could you paste the output of the following?

ll /var/www

Make sure to give the correct permission to the nagios directory, otherwise apache wont be able to access it.

0
 

Author Comment

by:itc_sysadmin
ID: 36485607
# ls -l /var/www
total 52
drwxr-xr-x  2 root  daemon   512 Mar 17  2010 bin
drwxr-xr-x  3 root  daemon   512 Sep  4 06:36 cgi-bin
drwxr-xr-x  6 root  daemon   512 Sep  4 15:24 conf
drwxr-xr-x  2 root  daemon   512 Sep  6 02:06 dev
drwxr-xr-x  3 root  daemon   512 Sep  4 06:33 etc
drwxr-xr-x  3 root  daemon   512 Aug 15 07:55 htdocs
drwxr-xr-x  3 root  daemon  3584 Aug 15 07:55 icons
drwxr-xr-x  2 root  daemon   512 Sep  6 02:06 logs
drwxr-xr-x  9 root  daemon   512 Sep  5 11:45 nagios
drwx-----T  2 www   www      512 Sep  4 06:33 tmp
drwxr-xr-x  2 root  daemon   512 Sep  4 15:16 users
drwxr-xr-x  4 root  daemon   512 Sep  4 06:33 var
#
0
 
LVL 13

Expert Comment

by:LinuxGuru
ID: 36486384
Hi,

The permissions seems to be correct. Did you check the installation by running the following command as mentioned in the documentation?

/usr/local/sbin/nagios -v /var/www/etc/nagios/nagios.cfg

??

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 13

Expert Comment

by:LinuxGuru
ID: 36486393
Also please go to the /var/www/nagios directory and create a .htaccess file there with the following content.

Options Indexes
0
 

Author Comment

by:itc_sysadmin
ID: 36486541
> Hi,

>The permissions seems to be correct. Did you check the installation by running the following command >as mentioned in the documentation?
>
>/usr/local/sbin/nagios -v /var/www/etc/nagios/nagios.cfg

> ??

I ran that with  no errors:

# /usr/local/sbin/nagios -v /var/www/etc/nagios/nagios.cfg

Nagios Core 3.2.0
Copyright (c) 2009 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-12-2009
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
Processing object config file '/etc/nagios/objects/commands.cfg'...
Processing object config file '/etc/nagios/objects/contacts.cfg'...
Processing object config file '/etc/nagios/objects/timeperiods.cfg'...
Processing object config file '/etc/nagios/objects/templates.cfg'...
Processing object config file '/etc/nagios/objects/localhost.cfg'...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
        Checked 8 services.
Checking hosts...
        Checked 1 hosts.
Checking host groups...
        Checked 1 host groups.
Checking service groups...
        Checked 0 service groups.
Checking contacts...
        Checked 1 contacts.
Checking contact groups...
        Checked 1 contact groups.
Checking service escalations...
        Checked 0 service escalations.
Checking service dependencies...
        Checked 0 service dependencies.
Checking host escalations...
        Checked 0 host escalations.
Checking host dependencies...
        Checked 0 host dependencies.
Checking commands...
        Checked 24 commands.
Checking time periods...
        Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
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
#
0
 

Author Comment

by:itc_sysadmin
ID: 36486558
Hi testez,

I created the .htaccess file in /var/www/nagios/ with Options Indexes, I still get the error.
0
 
LVL 13

Expert Comment

by:LinuxGuru
ID: 36486714
Ok. Sometimes SELinux may cause issues. Make sure to disable it. Also is there a file named index.html in your /var/www/nagios/ ?

Please paste the output of the following.

ls -l /var/www/nagios
0
 

Author Comment

by:itc_sysadmin
ID: 36493236
Hi,

Here it is.

# ls -l /var/www/nagios/
total 68
-rw-r--r--  1 root  daemon    16 Sep  6 11:27 .htaccess
-r--r--r--  1 root  bin      536 Mar 19  2010 config.inc.php
drwxr-xr-x  2 root  daemon  1536 Sep  4 06:37 contexthelp
drwxr-xr-x  3 root  daemon  2560 Sep  4 06:37 docs
drwxr-xr-x  3 root  daemon  1536 Sep  4 06:37 images
drwxr-xr-x  2 root  daemon   512 Sep  4 06:37 includes
-r--r--r--  1 root  bin      718 Mar 19  2010 index.php
-r--r--r--  1 root  bin     3420 Mar 19  2010 main.php
drwxr-xr-x  2 www   daemon   512 Sep  4 06:37 media
-r--r--r--  1 root  bin       26 Mar 19  2010 robots.txt
-r--r--r--  1 root  bin     5714 Mar 19  2010 side.php
drwxr-xr-x  2 root  daemon   512 Sep  4 06:37 ssi
drwxr-xr-x  2 root  daemon   512 Sep  4 06:37 stylesheets
0
 

Author Comment

by:itc_sysadmin
ID: 36493240
I'm using OpenBSD which uses PF. I have disabled pf.
0
 
LVL 13

Expert Comment

by:LinuxGuru
ID: 36494149
Ok. Please create a file index.html with no content and let me know the results.

You can use the following command

touch index.html
0
 

Author Comment

by:itc_sysadmin
ID: 36506988
Hi,

I've tried created the index.html to /var/www/nagios/  folder but still that error still comes up.

I might have rebuild it on another VM and retrace my steps again.

0
 
LVL 13

Accepted Solution

by:
LinuxGuru earned 500 total points
ID: 36508171
Ok.

Normally this can be caused by several things:

1. You have a .htaccess file in the web root directory which has a rule in it to prevent directory index browsing.
2. Your Apache configuration file (httpd.conf) has rules set to disallow directory index browsing.
3. You have no index.html file in that directory and thus it thinks it needs to attempt directory index browsing.
4. Your server doesn't have a rule to use index.php if no index.html file is found

I think we have already checked almost all possible reasons.

Also the ownership and permission for index.php, main.php, side.php, config.inc.php seems to be root:bin and 444. Could you change it to root:daemon and 644 and see the results.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Hi, in this article I'm going to teach you how to run your own site, and how to let people in (without IP). I'll talk about and explain each step... :) By the way, everything in this Tutorial is completely free and legal. This article is for …
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now