proxy_socket_keepalive how to?

Francis Daly francis at daoine.org
Fri Nov 27 11:58:40 UTC 2020


On Fri, Nov 27, 2020 at 06:29:16AM -0500, narksu wrote:

Hi there,

> I make a curl directly to backend
> from nginx server, there are tcp keepalive in tcpdump and I receive reply
> from backend in 40 minutes. Tried to use proxy_socket_keepalive=on in
> location section but tcpkeepalive not appear in tcpdump and session stil
> close by timeout. So what is the proper way to enable
> proxy_socket_keepalive?

The documentation at http://nginx.org/r/proxy_socket_keepalive suggests
that it is

  proxy_socket_keepalive on;

but gives no obvious way to set the idle/interval/count values, so
presumably it will use your system defaults for those. Maybe your system
says "don't send the first keepalive packet until two hours have passed".

If you are on something linuxy, files with names like
/proc/sys/net/ipv4/tcp_keepalive* or the output of something like

  /sbin/sysctl -ar tcp_keepalive

will probably be instructive; other systems presumably have their own
ways to configure things.

(If it is important to you to be able to set these values for nginx only,
then you could consider implementing what "listen" does, but for outgoing
connections, probably in src/http/ngx_http_upstream.c and friends. But
it is probably less work today, to change your system defaults to what
you want your nginx to use.)

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org


More information about the nginx mailing list