• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Debug link on NGINX = Bad Gateway

lasertits

Active member
#1
My server is running nginx with php-fpm. I have debug enabled but whenever I go to click the link (http://site.com/?_debug=1) I just get hit with

:(

Current config for the host:

Code:
        # web :: main server:
        server {
                server_name web;
                listen 80;
                listen 443 default ssl;

                access_log /var/www/logs/access_log main;
                error_log /var/www/logs/error_log info;

                root /var/www/htdocs;

                # private dirs:
                location ~ ^/(internal_data|library)/(.*)$ {
                    internal;
                }

                # clean urls:
                try_files $uri $uri/ /index.php?$uri&$args;

                location ~ .*.php$ {
                        fastcgi_pass unix:/etc/nginx/fcgi.socket;
                        fastcgi_index index.php;
              }
        }
any ideas? Perhaps something with fastcgi_index?
 

Jake Bunce

XenForo moderator
Staff member
#2

lasertits

Active member
#3
It's the link that appears in the footer if you enable debugging in your Xen config.php and as far as I know is the only link the bad gateway message appears on.

Thanks for the links, I'll give them a read and see if I come up with a solution. I'll update this thread later depending on the outcome.

If anyone else has any ideas please don't hesitate to post, I'll still be watching this spot as I troubleshoot. Thanks.
 

Jake Bunce

XenForo moderator
Staff member
#4
It's the link that appears in the footer if you enable debugging in your Xen config.php and as far as I know is the only link the bad gateway message appears on.
Oh yeah, that little link. o_O

Definitely check the server logs. Hopefully they will contain more information about the error.
 

lasertits

Active member
#5
error_log:
Code:
2011/10/02 23:18:02 [error] 4745#0: *8 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x, server: -snip-.com, request: "GET /?_debug=1 HTTP/1.1", upstream: "fastcgi://unix:/etc/nginx/fcgi.socket:", host: "-snip-.com", referrer: "http://-snip-.com/"
^ This occurs on every load / refresh.

access_log:
Code:
x.x.x.x - - [02/Oct/2011:23:18:02 -0500]  "GET /?_debug=1 HTTP/1.1" 502 340 "http://-snip-.com/" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20100101 Firefox/7.0.1" "-"
I suppose at this point I can probably take this to another site/forum and get feedback as well as it doesn't appear to be Xen specific, but rather to do with my fastcgi setup... :confused:
 

Mike

XenForo developer
Staff member
#6
I would bet that PHP is crashing. Kier has actually started seeing that at times (I haven't and this is the only other report of it), but it's somewhat random. It was triggered by the "EXPLAIN" queries, but I really don't know why. Could try a more recent PHP version (and possibly try a different MySQL library with PHP, like mysqlnd or the standard libmysql).
 

Luke F

Well-known member
#7
I would bet that PHP is crashing. Kier has actually started seeing that at times (I haven't and this is the only other report of it), but it's somewhat random. It was triggered by the "EXPLAIN" queries, but I really don't know why. Could try a more recent PHP version (and possibly try a different MySQL library with PHP, like mysqlnd or the standard libmysql).
I'm using mysqlnd and the latest php and mysql behind nginx and have never seen php processes crash.
 

Deebs

Well-known member
#12
I was never able to fix this, no. PHP 5.3.8, php-fpm, nginx 1.0.10
What are your settings for the following:

fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 600;
fastcgi_busy_buffers_size 512k;
fastcgi_temp_file_write_size 1M;
fastcgi_intercept_errors on;
Those are mine and the debug link works fine.
 

lasertits

Active member
#15
They live in the http context so I keep them in nginx.conf.
My nginx doesn't like that. :(
Code:
Black Cloud nginx # /etc/init.d/nginx restart
* Checking nginx' configuration ...
nginx: [emerg] "fastcgi_busy_buffers_size" must be less than the size of all "fastcgi_buffers" minus one buffer in /etc/nginx/nginx.conf:222
nginx: configuration file /etc/nginx/nginx.conf test failed
nginx: [emerg] "fastcgi_busy_buffers_size" must be less than the size of all "fastcgi_buffers" minus one buffer in /etc/nginx/nginx.conf:222
nginx: configuration file /etc/nginx/nginx.conf test failed
* failed, please correct errors above                                                                                                                                              [ !! ]
* ERROR: nginx failed to stop
While we're at it, mind sharing your location ~ .*.php$ { }?

Code:
                location ~ .*.php$ {
                        include /etc/nginx/fastcgi.conf;
                        fastcgi_pass unix:/etc/nginx/fcgi.socket;
                        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include        fastcgi_params;
                        fastcgi_index index.php;
                        }
 
              }
Thanks.

Edit: I commented out the busy_buffers line for now, got nginx to restart, reloaded the debug link and I'm still hit with 502 bad gateway. Snagged the error_log, this is what it says:

Code:
2012/01/14 02:44:16 [error] 30589#0: *4 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: x.x.x.x, server: -snip-, request: "GET /?_debug=1 HTTP/1.1", upstream: "fastcgi://unix:/etc/nginx/fcgi.socket:", host: "-snip-"
Which is the same error I got before.

And the access_log:
Code:
x.x.x.x - - [14/Jan/2012:02:44:16 -0600] "GET /?_debug=1 HTTP/1.1" 502 341 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0.1) Gecko/20100101 Firefox/9.0.1" "-"
 

Deebs

Well-known member
#16
My nginx doesn't like that. :(
Code:
Black Cloud nginx # /etc/init.d/nginx restart
* Checking nginx' configuration ...
nginx: [emerg] "fastcgi_busy_buffers_size" must be less than the size of all "fastcgi_buffers" minus one buffer in /etc/nginx/nginx.conf:222
nginx: configuration file /etc/nginx/nginx.conf test failed
nginx: [emerg] "fastcgi_busy_buffers_size" must be less than the size of all "fastcgi_buffers" minus one buffer in /etc/nginx/nginx.conf:222
nginx: configuration file /etc/nginx/nginx.conf test failed
* failed, please correct errors above                                                                                                                                              [ !! ]
* ERROR: nginx failed to stop
While we're at it, mind sharing your location ~ .*.php$ { }?

Code:
                location ~ .*.php$ {
                        include /etc/nginx/fastcgi.conf;
                        fastcgi_pass unix:/etc/nginx/fcgi.socket;
                        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        include        fastcgi_params;
                        fastcgi_index index.php;
                        }
 
              }
Thanks.
Here is my fastcgi_buffers
fastcgi_buffers 1024 4k;
location ~ \.php$ {

try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;

include /usr/local/nginx/conf/fastcgi_params;

fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_script_name;

# Allow nginx to do file uploads
client_body_temp_path /var/tmp/nginxuploads;
client_max_body_size 1G;
fastcgi_pass_request_body on;
fastcgi_param REQUEST_BODY_FILE $request_body_file;

fastcgi_param HTTPS on;
fastcgi_param X_FORWARDED_PROTO https;

fastcgi_pass phpfpm_backend;
}