Welcome! Log In Create A New Profile

Advanced

Re: Proxying request - HTTP/1.1 502 Bad Gateway

Maxim Dounin
August 09, 2011 05:02AM
Hello!

On Tue, Aug 09, 2011 at 02:12:19AM -0400, michalkraus wrote:

> Hello,
> we have problem with proxying some RPC (POST) requests to a backend
> server.
> When a request is sent without proxy to the backend directly everrything
> is OK. So problem is probably caused by nginx proxy.
> When the request is sent from the same server as proxy is installed,
> response is allways OK as well.
> The problem occurs just when a method with many parameters is called
> (large POST request). And the strangest thing is that the same request
> is sometimes OK and sometimes produces 502 Bad Gateway.
>
> A part of http section from nginx.conf:
> client_header_buffer_size 32k;
> large_client_header_buffers 4 64k;
> client_body_buffer_size 32k;
> proxy_buffer_size 32k;
> proxy_buffers 8 16k;
> proxy_busy_buffers_size 64k;
> sendfile on;
> #tcp_nopush on;
> tcp_nodelay on;
> keepalive_timeout 5;
> keepalive_requests 50;
> server_tokens off
>
> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>
> and the location just:
> location ~ "^/public/RPC2$" {

Just a side note: it's better to use

location = /public/RPC2 {

instead.

> proxy_pass http://localhost:3352;
> }
>
> Part of debug log, when the request is not processed correctly:

[...]

> 2011/08/08 16:05:25 [debug] 23971#0: *218 recv: fd:48 0 of 32768
> 2011/08/08 16:05:25 [error] 23971#0: *218 upstream prematurely closed
> connection while reading response header from upstream, client:
> 10.0.132.6, server: xxxxxxxxxxxx, request: "POST /public/RPC2 HTTP/1.1",
> upstream: "http://127.0.0.1:3352/public/RPC2", host: "yyyyyyyyyyyyyy"

Backend closed connection here. You may want to inspect backend
logs (or debug your backend) to find out why it did that.

While it certainly possible that backend doesn't like something in
nginx request (compared to direct one), it's not possible to say
what exactly without debugging backend.

Maxim Dounin

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Proxying request - HTTP/1.1 502 Bad Gateway

michalkraus August 09, 2011 02:12AM

Re: Proxying request - HTTP/1.1 502 Bad Gateway

Maxim Dounin August 09, 2011 05:02AM

Re: Proxying request - HTTP/1.1 502 Bad Gateway

michalkraus August 10, 2011 07:56AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 61
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready