ignore "connection: close" from upstream
francis at daoine.org
Tue Sep 15 08:01:21 UTC 2015
On Mon, Sep 14, 2015 at 01:48:45PM -0700, Frank Liu wrote:
There seems to be a few separate questions in here. I do not have useful
answers to all of them.
> I have below setup:
> client -> nginx server A -> proxy server -> real backend server (say,
> nginx server B)
nginx does not speak to a proxy server.
So either your proxy server is acting as a http server, or your
architecture is not going to work very well.
> I'd like to have the keepalive connection between nginx server A and proxy
> server never die.
That's a feature of the two servers -- so if you control them both,
you can have it be long-lasting. "never" is ambitious, but you may be
able to get "seldom enough".
> The problem is sometimes the real backend server sends a
> "Connection: close". For example, I know if nginx is used as the real
> backend server, it will by default send "Connection: close" after 100
> requests. When proxy server passes that response to nginx A, nginx will
> drop the keepalive link.
proxy server should not pass that response to nginx A.
RFC 2616 s13.5.1
Fix proxy server so that it does not, and your problem might disappear.
> Since I don't have control over the real backend server, my question is
> whether it is possible to configure nginx A to ignore the upstream
> "connection: close" and keep the link alive? Does nginx A have to pass the
> "Connection: close" to client? I thought nginx and client manage the
> keepalive separately instead of relying on upstream keepalive.
If "the thing talking to nginx" says "this connection is closing", it
would seem hopeful for nginx to keep talking on that connection -- there
is a good chance that the other end of the connection has already closed.
> I have control over the proxy server, so I could add a "X-My-Connection:
> close" or "X-My-Connection: keep-alive" to manage the connections between
> nginx server A and proxy server. Can nginx be configured to honor the
> customer header so that we don't be affected by the real backend server?
It sounds to me like your proxy server is not doing what a proxy
server should do. And, as nginx does not talk to a proxy server, your
architecture may be wrong.
Francis Daly francis at daoine.org
More information about the nginx