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

I have a server which needs to know when the client closes the connection. The server is behind an nginx reverse proxy. Everything works fine over HTTP, but as soon as I turn SSL on, nginx seems to hold the upstream connection open for a full minute after the HTTPS client has disconnected.

How can I get nginx to close the upstream connection when the client disconnects?

Here's my nginx config:

ssl_session_cache off;
server {
    listen 443;
    ssl on;
    ssl_certificate server.crt;
    ssl_certificate_key server.key;
    location /find {
      proxy_pass http://my_upstream;
      proxy_ignore_client_abort off;
      proxy_buffering off;
    }
  }
share|improve this question
    
Try proxy_ignore_client_abort on. Prevents aborting request to proxy in case the client itself aborts the request –  ooshro Feb 25 '11 at 0:38
    
that is exactly the behaviour I don't want. I want the proxy to abort the upstream connection as soon as the client closes the connection. –  nornagon Feb 25 '11 at 1:30

1 Answer 1

Quite late but might be helpful for others. I had the same problem and it turned out to be an issue with nginx (see https://www.ruby-forum.com/topic/4412004):

So the underlying problem is that the nginx stream layer abstraction isn't clean enough to handle low level OS events and then map them through the SSL layer to read/write/eof conceptual events as needed. Instead you need an OS level "eof" event, which you then assume maps through the SSL abstraction layer to a SSL stream eof event.

Ok, so I had a look at the kqueue eof handling, and what's needed for epoll eof handling, and created a quick patch that seems to work.

I applied the patch on 1.4.2 and it worked! No problems so far. Hopefully it will be fixed in one of the next releases.

Edited

This problem seems to be solved with nginx version >=1.5.5:

Feature: now nginx uses EPOLLRDHUP events to detect premature connection close by clients if the "epoll" method is used.

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.