Score:0

SSH tunnel HTTP/S, client connections stuck in FIN_WAIT2 status

jp flag

I've set up a tunnel successfully between two servers, such that incoming connections on port 80/443 are forwarded to another server that is actually running the webserver. Further, I've used autossh to maintain the connection.

This works great, except that instead of closing fully, many of the incoming connections end up in a state of FIN_WAIT2:

sample netstat output

..and since they are associated with a running process, they are never cleaned up by the system. Eventually, I hit the open files limit, resulting in the SSH client accepting no new connections. The problem is, I can't figure out why this is happening. Many of the incoming connections close cleanly, but others just persist infinitely.

Things I've tried:

  1. Disabling ServerAliveInterval/CountMax, ClientAliveInterval/CountMax, and TCPkeepAlive

  2. Restarting the service (works, but isn't really a solution)

The research I've done into this leads me to very few sources of information, such as this question on serverfault, which haven't offered any solution.

I don't understand how connections that aren't kept alive and from which the client has disconnected remain active. Can anyone shed some light?

djdomi avatar
za flag
autossh for http/https? Why not using a Reverse-Proxy like nginx? Always use K.I.S. - Keep It Simple
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.