Http keep alive with post requests issue

Hi,

I am using nginx as proxy with an upstream configuration:

upstream example_server {
server localhost:9000 fail_timeout=0;
keepalive 64;
}

Everything works fine when configuring location to include
proxy_http_version and connection header:

location … {
send_timeout 300;
client_body_buffer_size 1024k;
proxy_read_timeout 300;

      proxy_http_version 1.1;
      proxy_set_header Connection "";

            ...
            proxy_pass http://example_server;

}

Responses for both HTTP GET and POST requests contain “keep-alive” and
“server nginx” headers.
However, when I try to set proxy_http_version and connection header
within
server or http context instead of location, nginx will only proxy GET
requests. Responses for any POST requests seem to be coming directly
from
my application server (no keep-alive headers and server name contains
application server instead of nginx). What am I missing here?

Posted at Nginx Forum:

I figured that the location settings have not been used at all.
So now I can see that even for location settings the same error occurs.
If I
use keepalive and proxy_set_header Connection “” it works. As soon as I
add
“proxy_http_version 1.1” to any context, the POST responses still get
returned directly by the application server…

Posted at Nginx Forum:

On Monday 13 October 2014 10:48:26 lzilles wrote:

I figured that the location settings have not been used at all.
So now I can see that even for location settings the same error occurs. If I
use keepalive and proxy_set_header Connection “” it works. As soon as I add
“proxy_http_version 1.1” to any context, the POST responses still get
returned directly by the application server…

What do you mean by “returned directly”?

wbr, Valentin V. Bartenev

The http headers returned to the client are incorrect. It should be
“Connection ‘keep-alive’” instead of “Conncetion “close””. Somehow all
the
nginx settings for response headers seem to be ignored. The fact that
the
application server’s name is returned in the response http header
instead of
“Server nginx” made me think that the response is “directly” returned
without taking nginx configuration into account.
The requests get logged to access.log. I enabled further log statements
using “$sent_http_header” variables. Still I can’t figure out why the
GET
requests are treated differently.

Posted at Nginx Forum: