Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

On TCP connections held by NGinx, can it be configured to send TCP Keepalive

(Not HTTP KeepAlive!)

share|improve this question

5 Answers 5

Made it: https://github.com/nviennot/nginx-tcp-keepalive

share|improve this answer
    
does the existing listen option: so_keepalive not work? –  chacham15 Dec 5 at 9:29
    
As far as I see the so_keepalive is on per server basis since it is option to location directive. The module allows that configuration per location basis, that can be significant difference in some cases. –  myroslav Dec 12 at 9:57

Use the source, Luke.

(but why would you want to do such a thing?)

share|improve this answer
    
So our firewall would not disconnect long lived connections. –  ripper234 Oct 22 '10 at 20:51
1  
Why don't you just tell your firewall not to terminate long connections? –  symcbean Oct 25 '10 at 8:03
1  
Because there might be other firewalls along the way - I don't control them all. –  ripper234 Dec 3 '10 at 6:36

At the moment, only mail proxy module supports "so_keepalive" directive.

share|improve this answer

There is as LD_PRELOAD module that turns keepalives on, even if the app doesn't have an option to do so. (I don't know if it works with nginx or not.)

share|improve this answer

You have 2 options:

  • use stock so_keepalive nginx option
  • use nginx-tcp-keepalive module directives

listen ... so_keepalive=on

listen directive with so_keepalive option is server level. See http://nginx.org/en/docs/http/ngx_http_core_module.html#listen for full documentation. This option is available since 2011-12-12 in nginx 1.1.11 and later.

tcp_keepalive=on

The nginx-tcp-keepalive module of Nicolas Viennot provides family of tcp_keep* directives that are location level. This module should work properly on modern Linux and BSD systems. Mac OS X support is limited to tcp_keepalive only. The module was originally releases approximately in the moment when nginx gained the so_keepalive option. I hadn't tried if the module is still compatible with newer version of nginx.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.