FreeBSD 上的 Nagios Apache 403 被禁止

FreeBSD 上的 Nagios Apache 403 被禁止

我有以下配置文件/usr/local/etc/apache24/Includes,当我尝试登录 Nagios GUI 时,出现 403 禁止访问。我猜这是 Apache 访问 Nagios 数据的权限问题,但我不确定如何解决这个问题。我确实将www用户添加到了nagios组中,并且这些文件是/usr/local/www/nagios/cgi-bin/nagios 组可执行和可读的。我还在httpd.conf文件中启用了 cgi_modules

ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/

Alias /nagios /usr/local/www/nagios/
<Directory /usr/local/www/nagios>

   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthType Basic
   AuthUSerFile /usr/local/etc/nagios/htpasswd.users
   Require valid-user

</Directory>

<Directory /usr/local/www/nagios/cgi-bin>

   Options ExecCGI
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthType Basic
   AuthUSerFile /usr/local/etc/nagios/htpasswd.users
   Require valid-user

</Directory>

我该如何解决这个问题?

Nagios 版本:4.3.4

Apache 版本:24

FreeBSD 11

更新 1:

我修改了 httpd.conf 文件中的目录索引部分以包含 index.php

<IfModule dir_module>
    DirectoryIndex index.html index.php
</IfModule>

我看到以下网页

<?php
include_once(dirname(__FILE__).'/includes/utils.inc.php');
// Allow specifying main window URL for permalinks, etc.
$url = $cfg['cgi_base_url'].'/tac.cgi';

if ("yes" == "yes" && isset($_GET['corewindow'])) {

    // The default window url may have been overridden with a permalink...
    // Parse the URL and remove permalink option from base.
    $a = parse_url($_GET['corewindow']);

    // Build the base url.
    $url = htmlentities($a['path']).'?';
    $url = (isset($a['host'])) ? $a['scheme'].'://'.$a['host'].$url : '/'.$url;

    $query = isset($a['query']) ? $a['query'] : '';
    $pairs = explode('&', $query);
    foreach ($pairs as $pair) {
        $v = explode('=', $pair);
        if (is_array($v)) {
            $key = urlencode($v[0]);
            $val = urlencode(isset($v[1]) ? $v[1] : '');
            $url .= "&$key=$val";
        }
    }
    if (preg_match("/^http:\/\/|^https:\/\/|^\//", $url) != 1)
        $url = "main.php";
}

$this_year = '2017';
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">

<html>
<head>
    <meta name="ROBOTS" content="NOINDEX, NOFOLLOW">
<script LANGUAGE="javascript">
    var n = Math.round(Math.random() * 10000000000);
    document.write("<title>Nagios Core on " + window.location.hostname + "</title>");
    document.cookie = "NagFormId=" + n.toString(16);
</script>
    <link rel="shortcut icon" href="images/favicon.ico" type="image/ico">
</head>

<frameset cols="180,*" style="border: 0px;">
    <frame src="side.php" name="side" frameborder="0" style="">
    <frame src="<?php echo $url; ?>" name="main" frameborder="0" style="">

    <noframes>
        <!-- This page requires a web browser which supports frames. -->
        <h2>Nagios Core</h2>
        <p align="center">
            <a href="https://www.nagios.org/">www.nagios.org</a><br>
            Copyright &copy; 2010-<?php echo $this_year; ?> Nagios Core Development Team and Community Contributors.
            Copyright &copy; 1999-2010 Ethan Galstad<br>
        </p>
        <p>
            <i>Note: These pages require a browser which supports frames</i>
        </p>
    </noframes>
</frameset>

</html>

但错误Cannot serve directory /usr/local/www/nagios/: No matching DirectoryIndex (index.html) found, and server-generated directory index forbidden by Options directive还没有消失。

答案1

因此目录索引可能是这里的问题。

<IfModule dir_module>
    DirectoryIndex index.php index.html index.htm AddType application/x-httpd-php .phpAddType application/x-httpd-php-source .phps
</IfModule>

完整文档在这里: https://support.nagios.com/kb/article.php?id=96#FreeBSD

相关内容