FcgiWrap缺少参数 - Nagios安装

时间:2015-09-05 20:33:19

标签: nginx fastcgi nagios

我正在设置运行NGINX和PHP-FPM的服务器上设置Nagios。

我网站的nginx-config文件是:

server {

    listen 80;
    listen [::]:80;

    root /var/www/nagios;

    index index.html index.htm index.php;

    auth_basic "Nagios Restricted Access";
    auth_basic_user_file /usr/local/nagios/etc/htpasswd.users ;

    server_name <hidden for stackoverflow>;

    location / {
            root /var/www/nagios/html;
            try_files $uri $uri/ =404;
    }

    location ~ \.cgi$ {
            gzip off;
            root /var/www/nagios/cgi;
            include fastcgi_params;
            fastcgi_param DOCUMENT_ROOT $document_root;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_param SCRIPT_NAME $fastcgi_script_name;
            fastcgi_param AUTH_USER $remote_user;
            fastcgi_param REMOTE_USER $remote_user;
            fastcgi_pass unix:/var/run/fcgiwrap.socket;
    }

    location ~ \.php$ {
            root /var/www/nagios/html;
            try_files $uri =404;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass 127.0.0.1:9000;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

    location ~ /\.ht {
            deny all;
    }
}

Nagios安装在/var/www/nagios/。 PHP文件和html位于/var/www/nagios/html

CGI文件位于/var/www/nagios/cgi/

但是,当我尝试运行Nagios时,我在所有.cgi个文件页面上都禁止403。

当我尝试service fcgiwrap status时,我收到以下错误:

Cannot get script name, are DOCUMENT_ROOT and SCRIPT_NAME (or SCRIPT_FILENAME) set and is the script executable?

nginx error.log

中没有抛出任何错误

/var/www/nagios/cgi中的所有文件都是可执行文件,由www-data:www-data所有,属于/var/www/nagios/html

我不知道从哪里开始。有什么提示吗?

更新

我发现所有的CGI文件都是这样链接的: http://example.com/nagios/cgi-bin/status.cgi

当我访问这些时,我得到403 Forbidden错误,但如果我转到http://example.com/status.cgi,它就可以了。

所以我想我的新问题是:如何更改重写规则,以便将nagios/cgi-bin/status.cgi重写为/var/www/nagios/cgi/status.cgi的本地路径?

我猜,$fastcgi_script_name现在沿着nagios/cgi-bin/status.cgi的整个路径传递。

0 个答案:

没有答案