Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nginx overwrites general symfony errors with 502 Bad Gateway

Tags:

nginx

symfony

When I try to access a non-existing route or make a mistake inside a Twig template, instead of getting the Symfony error page with debug information, I get redirected to a default nginx 502 Bad Gateway.

The log shows an interesting line:

013/07/17 16:11:41 [error] 16952#0: *187 upstream sent too big header while reading
response header from upstream, client: 127.0.0.1, server: ftwo.localhost, request: "GET    
/heasd HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "ftwo.localhost"

Any ideas?

like image 594
Daniel Ribeiro Avatar asked Jul 17 '13 19:07

Daniel Ribeiro


People also ask

Why do I keep getting a 502 Bad gateway message?

A 502 bad gateway message indicates that one server got an invalid response from another. In essence, you've connected with some kind of interim device (like an edge server) that should fetch all of the bits you need to load the page. Something about that process went wrong, and the message indicates the problem.

Is a 502 Bad gateway my fault?

There is a good chance that if you have run into this error message while browsing, you're not at fault. Typically, an Error 502 bad gateway indicates that there is an issue with the website's server, rather than anything on your end.


2 Answers

Increase your buffer size in nginx configuration and restart nginx afterwards as suggested here.

proxy_buffer_size 128k;
proxy_buffers 4 256k;
proxy_busy_buffers_size 256k;

Further increase the fastcgi buffer in the php section of your configuration ( location ~ .php$ )

fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;

Referenced answer to a question from a CodeIgniter user here.

like image 117
Nicolai Fröhlich Avatar answered Sep 19 '22 11:09

Nicolai Fröhlich


You may also try to disable ChromePHP at app/config/config_dev.yml

Just comment out these lines:

chromephp:
    type:   chromephp
    level:  info

This plugin generates a large header and forces nginx to response with 502 Bad Gateway.

More info at:

https://github.com/symfony/symfony/issues/8413

Enable Debug Component in Symfony 2.3

like image 39
Alexey Morozov Avatar answered Sep 18 '22 11:09

Alexey Morozov