Page 1 of 1

nagios core generating error 403 forbidden

Posted: Thu Sep 22, 2022 6:14 am
by BabyTeanofred
I am configuring nagios core with nginx to monitor node js application. I have configured both nagios core and nginx server locally. Both is working fine. But when i want to open nagios core web page it gives 403 error forbidden.
nagios current status

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 status

● 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
nginx.confile which is configured inside /site-availabe/nginx.conf file

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"

Re: nagios core generating error 403 forbidden

Posted: Fri Jul 07, 2023 7:45 am
by nehakakar
Check that the Nagios files and directories have the correct permissions and are accessible by the web server user.

Re: nagios core generating error 403 forbidden

Posted: Sat Jul 08, 2023 2:03 am
by kg2857
2019/12/12 12:48:45 [error] 3976#3976: *1

2019 is a long time ago...

Re: nagios core generating error 403 forbidden

Posted: Mon Aug 14, 2023 12:49 am
by warrenfelsh
A "403 Forbidden" error may occur due to various reasons: insufficient permissions, lacking appropriate resource access, or misconfigured security settings. The server's settings could be wrongly configured, hindering access, while corrupted server files might also trigger this error. Additionally, during a DDoS attack, resource access could be temporarily blocked to safeguard against the attack.

To address a "403 Forbidden" error, consider these steps: Verify your permissions for resource access. Ensure the server's security settings aren't obstructing your access. Temporarily disable third-party browser extensions to eliminate potential conflicts. Reboot your device as a simple troubleshooting step. If issues persist, contacting the website administrator might be necessary after exhausting prior measures.