why "connection: close" header is added when the request is passed to upstream server?

Maxim Dounin mdounin at mdounin.ru
Thu Jan 19 13:23:23 UTC 2017


On Thu, Jan 19, 2017 at 09:02:34AM +0800, tjlp at sina.com wrote:

> I use Nginx in the Kubernetes. With the upstream server log, I 
> find that the header "connection: close" is added when the 
> request is passed to upstream server. Why?

Because the connection between nginx and the upstream server is a 
separate connection, and by default nginx isn't going to keep it 
alive.  Keepalive connections to upstream servers can be 
configured as documented here:


> What I hope is the original header relating to connection status 
> should be passed to upstream server without any change. That 
> means: if the original request header has no connection header, 
> "connection" header should not be added. 

The connection between nginx and the backend server is a 
completely separate connection, and it is expected to have it's 
own hop-by-hop headers, see RFC 2616 here:


Maxim Dounin

More information about the nginx mailing list