title: Nginx reverse proxy for Jersey SSE, CLOSE_WAIT connections eventually choke server
body: <p>I have a java webapp that uses Jersey SSE, when I directly connect to my tomcat instance, the no: of CLOSE_WAIT connections does not grow.(verified this with cURL)</p>
  
  <p>When I go through the nginx reverse proxy, connections related to the SSE call keep growing (in CLOSE_WAIT) and finally the server process chokes, and needs a restart. Given below is my config, I am guessing that nginx closes the connection every 60s and then creates a new one for the next SSE request, any ideas how to fix this ?</p>
  
  <pre><code>upstream tomcat {
      server 192.168.10.101:8443;
      server 192.168.10.102:8443;
      keepalive 16;
  }
  server {
  listen       443 ssl;
  #server_name  192.168.10.100;
  server_name myserver.home.net;
  
  ssl_certificate      /opt/mount/config/certs/test_ssl.pem;
  ssl_certificate_key  /opt/mount/config/certs/test_ssl_cert.key;
  
  ssl_session_cache shared:SSL:1m;
  ssl_session_timeout  5m;
  
  ssl_ciphers RC4:HIGH:!aNULL:!MD5;
  ssl_prefer_server_ciphers on;
  keepalive_timeout 180s;
  
  
  location / {
      proxy_pass             https://tomcat/mydashboard/;
      proxy_set_header       X-Real-IP $remote_addr;
      proxy_set_header       X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header       Host $http_host;
      proxy_redirect off;
      proxy_http_version 1.1;
      proxy_set_header Connection "";
      chunked_transfer_encoding off;
      proxy_cookie_domain     ~(.*)$  ws1.home.net;
      rewrite ^/dashboard/(.*)$ /$1 last;
  
  }
  </code></pre>
  
  <p>}</p>