nagios core禁止生成错误403

时间:2019-12-11 12:54:30

标签: nginx nagios

我正在用nginx配置nagios核心以监视节点js应用程序。我已经在本地配置了nagios core和nginx服务器。两者都工作正常。但是,当我想打开nagios核心网页时,它会禁止403错误。 when try to open http://ipaddress/nagios**strong text**

nagios当前状态

   Loaded: loaded (/etc/systemd/system/nagios.service; enabled; vendor preset: 
   Active: active (running) since Wed 2019-12-11 16:40:31 IST; 1h 56min ago
 Main PID: 2708 (nagios)
    Tasks: 6 (limit: 2319)
   CGroup: /system.slice/nagios.service
           ├─2708 /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
           ├─2709 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/r
           ├─2710 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/r
           ├─2711 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/r
           ├─2712 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/r
           └─2713 /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg

Dec 11 16:40:31 parth-VirtualBox nagios[2708]: wproc: Registry request: name=Co
Dec 11 16:40:31 parth-VirtualBox nagios[2708]: qh: help for the query handler r
Dec 11 16:40:31 parth-VirtualBox nagios[2708]: wproc: Successfully registered m
Dec 11 16:40:31 parth-VirtualBox nagios[2708]: wproc: Registry request: name=Co
Dec 11 16:40:31 parth-VirtualBox nagios[2708]: wproc: Registry request: name=Co
Dec 11 16:40:31 parth-VirtualBox nagios[2708]: wproc: Registry request: name=Co
Dec 11 16:40:31 parth-VirtualBox nagios[2708]: wproc: Registry request: name=Co
Dec 11 16:40:31 parth-VirtualBox nagios[2708]: Successfully launched command fi
Dec 11 16:40:31 parth-VirtualBox nagios[2708]: Successfully launched command fi
Dec 11 17:40:31 parth-VirtualBox nagios[2708]: Auto-save of retention data comp**strong text**

nginx状态

● nginx.service - A high performance web server and a reverse proxy server
   Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: e
   Active: active (running) since Wed 2019-12-11 16:48:16 IST; 1h 51min ago
     Docs: man:nginx(8)
  Process: 2831 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 
  Process: 3279 ExecReload=/usr/sbin/nginx -g daemon on; master_process on; -s 
  Process: 2833 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (cod
  Process: 2832 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process
 Main PID: 2834 (nginx)
    Tasks: 2 (limit: 2319)
   CGroup: /system.slice/nginx.service
           ├─2834 nginx: master process /usr/sbin/nginx -g daemon on; master_pr
           └─3280 nginx: worker process

Dec 11 16:48:16 parth-VirtualBox systemd[1]: Starting A high performance web se
Dec 11 16:48:16 parth-VirtualBox nginx[2832]: nginx: [warn] conflicting server 
Dec 11 16:48:16 parth-VirtualBox nginx[2832]: nginx: [warn] conflicting server 
Dec 11 16:48:16 parth-VirtualBox nginx[2833]: nginx: [warn] conflicting server 
Dec 11 16:48:16 parth-VirtualBox nginx[2833]: nginx: [warn] conflicting server 
Dec 11 16:48:16 parth-VirtualBox systemd[1]: nginx.service: Failed to parse PID
Dec 11 16:48:16 parth-VirtualBox systemd[1]: Started A high performance web ser
Dec 11 17:46:00 parth-VirtualBox systemd[1]: Reloading A high performance web s
Dec 11 17:46:00 parth-VirtualBox nginx[3279]: nginx: [warn] conflicting server 
Dec 11 17:46:00 parth-VirtualBox systemd[1]: Reloaded A high performance web se

在/site-availabe/nginx.conf文件中配置的nginx.confile

server {
    listen 80;
    server_name ipaddress;
    return 301 https://ipaddress$request_uri;
}

server {
    listen 443 ssl;

    server_name ipaddress;

    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;

    ssl_session_cache shared:SSL:20m;
    ssl_session_timeout 180m;

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

    ssl_prefer_server_ciphers on;
    ssl_ciphers ECADH+AQESGCM:ECDH+AEOS256:ECODH+AES128:DH+3DES:!ADH:!AECDH:!MD5;

    ssl_dhparam /etc/nginx/ssl/dhparam.pem;

    add_header Strict-Transport-Security "max-age=31536000";

    access_log /var/log/nginx/nagioshost.local-access.log;
    error_log /var/log/nginx/nagioshost.local-error.log;

    auth_basic "Private";
    auth_basic_user_file /etc/nginx/.htpasswds/nagios;

    root /var/www/vhosts/nagioshost.local;
    index index.php index.html;

    location / {
        try_files $uri $uri/ index.php /nagios;
    }

    location /nagios {
        alias /usr/local/nagios/share;
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_param AUTH_USER $remote_user;
            fastcgi_param REMOTE_USER $remote_user;
            fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
        location ~ \.cgi$ {
            root /usr/local/nagios/sbin;
            rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
            include /etc/nginx/fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $request_filename;
            fastcgi_param AUTH_USER $remote_user;
            fastcgi_param REMOTE_USER $remote_user;
            fastcgi_pass unix:/var/run/fcgiwrap.socket;
        }
    }

    location ~ ^/nagiosgraph/cgi-bin/(.*\.cgi)$ {
        alias /usr/local/nagiosgraph/cgi/$1;
        include /etc/nginx/fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $request_filename;
        fastcgi_param AUTH_USER $remote_user;
        fastcgi_param REMOTE_USER $remote_user;
        fastcgi_pass unix:/var/run/fcgiwrap.socket;
    }

    location /nagiosgraph {
        alias /usr/local/nagiosgraph/share;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
    }
}

nagios-access.log

12.xx.xx.xx - - [12/Dec/2019:11:00:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:11:00:49 +0530] "GET /favicon.ico HTTP/1.1" 401 204 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - - [12/Dec/2019:11:00:54 +0530] "GET /nagios/ HTTP/1.1" 401 204 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - nagiosadmin [12/Dec/2019:11:00:59 +0530] "GET /nagios/ HTTP/1.1" 403 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - - [12/Dec/2019:11:00:59 +0530] "GET /favicon.ico HTTP/1.1" 401 204 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - - [12/Dec/2019:11:05:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:11:10:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:11:15:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:11:20:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:11:25:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:11:30:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:11:35:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:11:40:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:11:45:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - nagiosadmin [12/Dec/2019:11:51:27 +0530] "GET /nagios/ HTTP/1.1" 403 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - nagiosadmin [12/Dec/2019:11:51:28 +0530] "GET /nagios/ HTTP/1.1" 403 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - nagiosadmin [12/Dec/2019:11:51:29 +0530] "GET /nagios/ HTTP/1.1" 403 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - nagiosadmin [12/Dec/2019:11:51:30 +0530] "GET /nagios/ HTTP/1.1" 403 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - - [12/Dec/2019:11:51:35 +0530] "GET / HTTP/1.1" 401 204 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - nagiosadmin [12/Dec/2019:11:51:35 +0530] "GET / HTTP/1.1" 403 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - nagiosadmin [12/Dec/2019:11:51:41 +0530] "GET /nagios/ HTTP/1.1" 403 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - nagiosadmin [12/Dec/2019:12:01:37 +0530] "GET /nagios/ HTTP/1.1" 403 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - nagiosadmin [12/Dec/2019:12:01:37 +0530] "GET /favicon.ico HTTP/1.1" 403 152 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:71.0) Gecko/20100101 Firefox/71.0"
12.xx.xx.xx - - [12/Dec/2019:12:05:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"
12.xx.xx.xx - - [12/Dec/2019:12:10:46 +0530] "GET / HTTP/1.1" 401 204 "-" "check_http/v2.2.1.git (nagios-plugins 2.2.1)"

nagios-error.log

2019/12/12 12:48:45 [error] 3976#3976: *1 open() "/usr/local/nagios/passwd" failed (2: No such file or directory), client: 12.xx.xx.xx, server: 12.xx.xx.xx, request: "GET /nagios/ HTTP/1.1", host: "12.xx.xx.xx"
2019/12/12 12:48:45 [error] 3976#3976: *1 open() "/usr/local/nagios/passwd" failed (2: No such file or directory), client: 12.xx.xx.xx, server: 12.xx.xx.xx, request: "GET /nagios/ HTTP/1.1", host: "12.xx.xx.xx"
2019/12/12 12:48:45 [error] 3976#3976: *1 open() "/usr/local/nagios/passwd" failed (2: No such file or directory), client: 12.xx.xx.xx, server: 12.xx.xx.xx, request: "GET /favicon.ico HTTP/1.1", host: "12.xx.xx.xx"
2019/12/12 12:48:45 [error] 3976#3976: *1 open() "/usr/local/nagios/passwd" failed (2: No such file or directory), client: 12.xx.xx.xx, server: 12.xx.xx.xx, request: "GET /nagios/ HTTP/1.1", host: "12.xx.xx.xx"
2019/12/12 12:48:46 [error] 3976#3976: *1 open() "/usr/local/nagios/passwd" failed (2: No such file or directory), client: 12.xx.xx.xx, server: 12.xx.xx.xx, request: "GET /nagios/ HTTP/1.1", host: "12.xx.xx.xx"

1 个答案:

答案 0 :(得分:0)

您的问题在这里,请检查/site-availabe/nginx.conf ” auth_basic_user_file /etc/nginx/.htpasswds/nagios;并将其更改为/ usr / local / nagios / passwd ” 也将/ usr / local / nagios / passwd所有权更改为root:nginx。