
우분투 20.04 시스템에 모두 역방향 프록시 설정 nginx 호스트 -> nagios가 있습니다. 이는 사용자 정의되지 않은 기본 apt-get 설치와 같습니다. 테스트용으로 자체 서명된 인증서를 추가했습니다.
192.168.254.107 - nginx 192.168.254.200 - 나기오스
문제는 cgi-bin이 리디렉션되지 않은 것 같고 nginx 자체에서 제공된다는 것입니다.
Nginx 구성
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;
}
}
오류
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"
다른 브라우저에서 열려고 하면 nginx 호스트에서 경로를 찾는다는 것을 알았습니다...
https://192.168.254.107/cgi-bin/nagios4/status.cgi?hostgroup=all&style=hostdetail
답변1
문제는 아마도 구성의 다음 두 줄일 것입니다.
location /nagios4 {
proxy_pass https://192.168.254.200/nagios4;
모든 위치를 프록시로 전달하려면 지시문 nagios4
에서 제거 하거나 지시문 에서 제거하십시오 . .location
/nagios4
proxy_pass
nagios4
cgi-bin
extinfo.cgi
답변2
나는 같은 문제를 발견했고 그것은 오래되었지만 여전히 HTTP에서 작동했습니다. 자체 서명된 인증서를 사용하기 때문에 https를 시도하지 않았습니다.
주요 문제는 cgi-bin이 백엔드가 아닌 nginx 폴더/호스트에서 계속 호출된다는 것입니다. 이로 인해 문제가 해결되었고 호출이 백엔드로 리디렉션되었습니다.
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;
}