0

I have a reverse proxy setup nginx host -> nagios both on ubuntu 20.04 machines virtual these are like just default apt-get install not customized. I added selfsigned certificate just for test.

192.168.254.107 - nginx 192.168.254.200 - nagios

The problem is that the cgi-bin seems not redirected and is being served on nginx itself

Nginx config

server {
    listen 443 ssl;
    listen 80 default_server;
    ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt;
    ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;
    ssl_session_cache shared:SSL:1m;
    ssl_session_timeout 2m;

    location /nagios4 {
        proxy_pass https://192.168.254.200/nagios4;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
    }
}

Error

2020/12/02 05:08:53 [error] 2307#2307: *21 open() "/usr/share/nginx/html/cgi-bin/nagios4/avail.cgi" failed (2: No such file or directory), client: 192.168.254.163, server: , request: "GET /cgi-bin/nagios4/avail.cgi HTTP/1.1", host: "192.168.254.107", referrer: "https://192.168.254.107/nagios4/side.php"
2020/12/02 05:08:58 [error] 2307#2307: *21 open() "/usr/share/nginx/html/cgi-bin/nagios4/extinfo.cgi" failed (2: No such file or directory), client: 192.168.254.163, server: , request: "GET /cgi-bin/nagios4/extinfo.cgi?type=3 HTTP/1.1", host: "192.168.254.107", referrer: "https://192.168.254.107/nagios4/side.php"
2020/12/02 05:09:02 [error] 2307#2307: *21 open() "/usr/share/nginx/html/cgi-bin/nagios4/extinfo.cgi" failed (2: No such file or directory), client: 192.168.254.163, server: , request: "GET /cgi-bin/nagios4/extinfo.cgi?type=6 HTTP/1.1", host: "192.168.254.107", referrer: "https://192.168.254.107/nagios4/side.php"
2020/12/02 05:09:02 [error] 2307#2307: *21 open() "/usr/share/nginx/html/cgi-bin/nagios4/extinfo.cgi" failed (2: No such file or directory), client: 192.168.254.163, server: , request: "GET /cgi-bin/nagios4/extinfo.cgi?type=0 HTTP/1.1", host: "192.168.254.107", referrer: "https://192.168.254.107/nagios4/side.php"
2020/12/02 05:09:03 [error] 2307#2307: *21 open() "/usr/share/nginx/html/cgi-bin/nagios4/extinfo.cgi" failed (2: No such file or directory), client: 192.168.254.163, server: , request: "GET /cgi-bin/nagios4/extinfo.cgi?type=4 HTTP/1.1", host: "192.168.254.107", referrer: "https://192.168.254.107/nagios4/side.php"

I noticed this when i tried open in another browser it goes and looks for the path on the nginx host...

https://192.168.254.107/cgi-bin/nagios4/status.cgi?hostgroup=all&style=hostdetail

2 Answers 2

0

The problem is probably these two lines of your configuration:

location /nagios4 {
    proxy_pass https://192.168.254.200/nagios4;

Either remove nagios4 in the location directive to forward all locations to the proxy or
remove the /nagios4 from the proxy_pass directive.
You can see from the error logs that nagios4 appears between the cgi-bin directory and the actual cgi file like extinfo.cgi.

0

I found the same problem and it was old but still worked for HTTP . I haven't tried https due Im using selfsigned certificate

The main issue is the cgi-bin is being called still on nginx folder/host and not in backend. This fixed it and redirecting the call to the backend.

     location /cgi-bin/nagios3/ {
          proxy_pass https://nagios.localdomain.com/cgi-bin/nagios3/;
          proxy_redirect default;
     }

     location /nagios3/ {
          proxy_pass  https://nagios.localdomain.com/nagios3/;
          proxy_redirect default;
     }

     location /nagios/ {
          proxy_pass  https://nagios.localdomain.com/nagios3/;
          proxy_redirect default;
     }

http://mailman.nginx.org/pipermail/nginx/2008-April/004623.htmlhttps://web.archive.org/web/20090209033420/http://wiki.codemongers.com/NginxProxyNagios

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .