无法使用 nagios 和 nginx 访问本地主机

无法使用 nagios 和 nginx 访问本地主机

我已经关注此链接要安装 nagios,我已经启动并运行了 nginx。问题是我不断获取用户名和密码进行身份验证。

当我删除 时auth_basic_user_file /etc/nagios/htpasswd.users;,我不会再收到该警报。但是http://localhost/nagios给了我空白页。然后当我使用 get that line back 时,我无法访问它。我甚至尝试了chown nagios /etc/nagios/htpasswd.users解决方案在此主题中

这是我的文件

htpasswd.用户

yamen:NFy9PslWPh4Vo

我的网站

   server {
            server_name *********************************;
            access_log /var/log/nginx/access.log;
            error_log /var/log/nginx/error.log;
            auth_basic      "Yamen's Area!";
            auth_basic_user_file  /etc/nagios/htpasswd.users;
            root /home/yamen/repos/autoban-md/;
            index index.php index.html index.htm;
            #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location / {
                    try_files $uri $uri/ /index.php;
            }
            location /nagios {
                    alias /opt/nagios/nagios/share;
            }
            location ~ ^/nagios/(.*\.php)$ {
                    alias /opt/nagios/nagios/share/$1;
                    include /etc/nginx/fastcgi_params;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
            }
            location ~ \.cgi$ {
                    root /opt/nagios/nagios/sbin/;
                    rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
                    fastcgi_param AUTH_USER $remote_user;
                    fastcgi_param REMOTE_USER $remote_user;
                    include /etc/nginx/fastcgi_params;
                    fastcgi_pass unix:/var/run/fcgiwrap.socket;
            }
            error_page 404 /404.html;
            error_page 500 502 503 504 /50x.html;
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            location ~\.php$ {
                    try_files $uri =404;
                    fastcgi_split_path_info ^(.+\.php)(/.+)$;
                    fastcgi_pass unix:/var/run/php5-fpm.sock;
                    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                    fastcgi_index  index.php;
                    include fastcgi_params;
            }
            location ~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
                    add_header "" "";
            }
            location ~ "^/pagespeed_static/" { }
            location ~ "^/ngx_pagespeed_beacon$" { }
    }

没有nagios.conf提供任何东西。

我输入上述用户名和密码,但什么也没发生

感谢@PaulHaldane,我确实发现了错误,但仍然不知道为什么会发生。这是 nginx 错误日志。

*108 user "yamen": password mismatch, client: 127.0.0.1, server: *************

答案1

问题是我手动更改了 htpasswd.users。因此运行后

htpasswd.py -c -b /etc/nagios/htpasswd.users yamen yamen

问题解决了:)

相关内容