Confused between proxy_socket_keepalive & (upstream) keepalive?

Maxim Dounin mdounin at mdounin.ru
Mon Apr 6 15:33:05 UTC 2020


Hello!

On Mon, Apr 06, 2020 at 09:55:44AM -0500, J.R. wrote:

> For my setup I use the 'upstream' directive, and in that module there
> is the 'keepalive' syntax:
> 
> https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive
> 
> I just noticed today in the proxy module there is the
> 'proxy_socket_keepalive' syntax:
> 
> http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_socket_keepalive
> 
> I'm a little confused... The upstream you set the # of keepalive
> connections you want. The proxy module is just an on/off...

The "proxy_socket_keepalive" directive is to set the SO_KEEPALIVE 
socket option, which is to detect broken connections by sending 
TCP keepalive probes periodically.  It is may make sense to turn 
this on in complex setups if there are upstream connections which 
does not transfer anything for a long time (for example, when 
proxying WebSockets with large timeouts).  For client-side 
connections, the same option can be set using the "so_keepalive" 
parameter of the "listen" directive.

While the name is somewhat similar, it is unrelated to keeping 
connections alive between requests.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list