Erro 502 Bad Gateway help

Francis Daly francis at daoine.org
Sat Jul 2 07:25:19 UTC 2016


On Sat, Jul 02, 2016 at 06:21:38AM +0000, yair avendaño wrote:

Hi there,

> Hi I'm setting up a nginx as a reverse proxy but to try to see a site with drupal locally that have shown me 502 Bad Gateway error.

"drupal" is possibly served by a http server, not a fastcgi server.

> this gets me in the logs.
> 
> 
> 016/07/02 00:51:57 [error] 18120#0: *61 upstream sent unsupported FastCGI protocol version: 72 while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:8080", host: " localhost"

If you make a bad http request to a http server, it will likely return
something that starts with "HTTP". The decimal value of ascii "H" is
"72"; a fastcgi client may expect the first octet to refer to the fastcgi
protocol version.

So your error message hints that your upstream is not a fastcgi server
but is a http server.

Which in turn suggests that the fix is:

>                          location ~ \.php$ {
>                        # Test for non-existent scripts or throw a 404 error
>                        # Without this line, nginx will blindly send any request ending in .php to php-fpm
>                        try_files $uri =404;
>                         include /etc/nginx/fastcgi.conf;

* delete those two

>                        fastcgi_pass 127.0.0.1:8080;  ## Make sure the socket corresponds with PHP-FPM conf file

* replace that with

    proxy_pass http://127.0.0.1:8080;


	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list