[PATCH 0 of 1] Upstream: add propagate_connection_close directive

Maxim Dounin mdounin at mdounin.ru
Mon Jan 5 03:47:44 UTC 2015


Hello!

On Fri, Jan 02, 2015 at 04:03:58PM -0800, Shawn J. Goff wrote:

> This patch adds a new directive to the upstream module:
> propagate_connection_close. It puts a "Connection: close" header in
> the downstream response if the upstream server sent one. This is
> useful when Nginx is used as HTTP/HTTPS endpoints with load blancers
> in front of them. It allows the upstream server to close connections
> in order to shed load.

You may try to better elaborate on the problem you are trying to 
solve and why existing mechanisms do not work for you.

As of now, nginx can:

- Disable keepalive completely ("keepalive_timeout 0") on a 
  per-location basis (http://nginx.org/r/keepalive_timeout).

- Disable keepalive based on a number of requests served in a 
  connection (http://nginx.org/r/keepalive_requests).

- Disable keepalive in some specific conditions 
  (http://nginx.org/r/keepalive_disable).

- Disable chunked transfer encoding on a per-location basis 
  (http://nginx.org/r/chunked_transfer_encoding).

I think this addresses most, if not all, problems in the links you 
provided.  In particular, low enough keepalive_requests can be 
used to distribute load if needed.

> I can submit a documentation patch if this patch is accepted.

The approach taken in the patch looks wrong, for multiple reasons, 
in particular:

- The upstream module isn't expected to contain it's own 
  directives, expect ones used to define upstream{} blocks.  
  Instead, there should be directives in modules implementing 
  protocols, like "proxy_foo_bar...".

- The "Connection: close" header is a hop-by-hop http header, and 
  "propogating" it looks like a bad idea.  It mixes control of the 
  nginx-to-backend connection with control of the client-to-nginx 
  connection.  Instead, there should be a way to control these 
  connections separately.  It may be an option to add X-Accel-... 
  header instead, similart to X-Accel-Limit-Rate.  Though this 
  approach has it's own problems too, see below.

- It is not possible to control connections that aren't proxied 
  to backends but are handled locally - e.g., when using embedded 
  perl or even just serving static files.

If there is a need to allow dynamic control of keepalive, I think 
that proper way would be to extend the "keepalive_disable" 
directive with variables support.

-- 
Maxim Dounin
http://nginx.org/



More information about the nginx-devel mailing list