I'm using nginx in reverse-proxy mode. Here's relevant part of config file:
server {
listen 80;
server_name ~^web.redhelper\.ru$ ;
access_log off;
location /http-bind {
proxy_pass http://localhost:7070;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $http_host;
}
}
After some some time I started to hit 500 error. I think that I'm hitting some max open connections limit. Here's munin graph:
When I use netstat I see that there are:
1279 open connections to port 80; (including website itself that is on the same port)
of them 745 are in ESTABLISHED state and 479 in TIME_WAIT
277 ESTABLISHED connections from 127.0.0.1:[misc port] to 127.0.0.1:7070
3922 connections from 127.0.0.1:7070 to 127.0.0.1:[misc port]
of them 246 are in ESTABLISHED state and 3646 in TIME_WAIT
I think that it is 3646 TIME_WAIT connections causing this. How can I prevent nginx from holding that much open connections?
Here are some more munin graphs, maybe they will help to better understand my problem: http://munin.redhelper.ru/localdomain/localhost.localdomain/index.html