Welcome! Log In Create A New Profile

Advanced

Nginx + fastCGI = 502 bad gateway

August 03, 2011 04:51AM
Greetings

I'm trying to setup Nagios web interface to work with Nginx, but I'm showed a 502 Bad Gateway just after login.

This is the nginx log (10.82.1.158 is the server and 10.82.1.106 is the client):

==> /var/log/nginx/access.https.log <==
10.82.1.106 - swissmsnagios [02/Aug/2011:17:19:15 +0200] "GET /cgi-bin/nagios3/tac.cgi HTTP/1.1" 502 173 "https://10.82.1.158/nagios3/side.html" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.30 (KHTML, like Gecko) Ubuntu/11.04 Chromium/12.0.742.112 Chrome/12.0.742.112 Safari/534.30"

==> /var/log/nginx/error.https.log <==
2011/08/02 17:19:15 [warn] 1161#0: *57 using uninitialized "script" variable, client: 10.82.1.106, server: vb5, request: "GET /cgi-bin/nagios3/tac.cgi HTTP/1.1", host: "10.82.1.158", referrer: "https://10.82.1.158/nagios3/side.html"
2011/08/02 17:19:15 [warn] 1161#0: *57 using uninitialized "path_info" variable, client: 10.82.1.106, server: vb5, request: "GET /cgi-bin/nagios3/tac.cgi HTTP/1.1", host: "10.82.1.158", referrer: "https://10.82.1.158/nagios3/side.html"
2011/08/02 17:19:15 [error] 1161#0: *57 connect() failed (111: Connection refused) while connecting to upstream, client: 10.82.1.106, server: vb5, request: "GET /cgi-bin/nagios3/tac.cgi HTTP/1.1", upstream: "fastcgi://127.0.0.1:49233", host: "10.82.1.158", referrer: "https://10.82.1.158/nagios3/side.html"

Relevant entry at Nginx configuration:

location ~ ^/cgi-bin/nagios3($|/.*) {
alias /usr/lib/cgi-bin/nagios3$1;

fastcgi_pass 127.0.0.1:49233;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

auth_basic "Nagios Access";
auth_basic_user_file /etc/nagios3/htpasswd.users;

fastcgi_param AUTH_USER $remote_user;
fastcgi_param REMOTE_USER $remote_user;

fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $script;
fastcgi_param PATH_INFO $path_info;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL HTTP/1.0;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
}

Things tested:

- Comment the alias sentence (http://forum.nginx.org/read.php?2,212501,212501)
- Switch from "fastcgi_pass 127.0.0.1:49233;" to "fastcgi_pass 127.0.0.1:3590;" (as netstat showed)

Additional info:

$ nginx -V
nginx version: nginx/0.7.65
TLS SNI support enabled
configure arguments: --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx.lock --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/var/lib/nginx/body --http-proxy-temp-path=/var/lib/nginx/proxy --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --with-debug --with-http_stub_status_module --with-http_flv_module --with-http_ssl_module --with-http_dav_module --with-http_gzip_static_module --with-http_realip_module --with-mail --with-mail_ssl_module --with-ipv6 --add-module=/build/buildd/nginx-0.7.65/modules/nginx-upstream-fair

$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=10.04
DISTRIB_CODENAME=lucid
DISTRIB_DESCRIPTION="Ubuntu 10.04.3 LTS"

$ dpkg -l | grep cgi
ii fcgiwrap 1.0-1 simple server to run CGI applications over F
ii libfcgi0ldbl 2.4.0-8 Shared library of FastCGI
ii nagios3-cgi 3.2.0-4ubuntu2.2 cgi files for nagios3
ii php5-cgi 5.3.2-1ubuntu4.9 server-side, HTML-embedded scripting languag
ii spawn-fcgi 1.6.3-1 A fastcgi process spawner

$ sudo netstat -anp | grep cgi
tcp 0 0 127.0.0.1:9001 0.0.0.0:* LISTEN 686/php-cgi
tcp 0 0 127.0.0.1:9002 0.0.0.0:* LISTEN 692/php-cgi
unix 2 [ ACC ] STREAM LISTENING 3590 738/fcgiwrap /var/run/fcgiwrap.socket

Thanks in advance.
Subject Author Posted

Nginx + fastCGI = 502 bad gateway

dekar411 August 03, 2011 04:51AM

Re: Nginx + fastCGI = 502 bad gateway

Edho Arief August 03, 2011 05:04AM

Re: Nginx + fastCGI = 502 bad gateway

dekar411 August 03, 2011 10:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 143
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready