Nginx version: 1.2.9 ( it's actually tengine/2.0.0 but the question is about nginx )
This is the config i'm using to create a forward proxy of sorts but i'm having problems.
server {
default_type text/html;
keepalive_requests 0;
listen 8080;
resolver 8.8.8.8 8.8.4.4;
resolver_timeout 10s;
proxy_bind $server_addr;
proxy_buffering off;
access_log off;
location / {
proxy_pass http://$http_host$uri$is_args$args;
proxy_pass_header Server;
proxy_pass_header Date;
proxy_ignore_headers X-Accel-Expires X-Accel-Redirect X-Accel-Limit-Rate X-Accel-Buffering X-Accel-Charset;
proxy_set_header Host $host;
}
}
Nginx seems to keep the udp sockets to the resolver open, i've compiled nginx with debug and watched the log for "ngx_log_debug0(NGX_LOG_DEBUG_CORE, ngx_cycle->log, 0,
"cleanup resolver");
but it seems to only get triggered when you reload the configuration.
In time the connections stack up untill there are no more free udp sockets and you start getting errors like:
2014/10/09 16:50:37 [crit] 11364#0: connect() failed (11: Resource temporarily unavailable) while resolving, resolver: 8.8.8.8:53
2014/10/09 16:50:37 [crit] 11387#0: send() incomplete while resolving, resolver: 8.8.8.8:53
from nginx and
"isc_socket_bind: address in use"
from other tools that use udp.
This becomes a problem in minutes if you set a very large number of workers ( 100+ )
Setting the worker count to 2*cores slowes this alot but in time ( maybe a few hours to 1-2 days ) it might happen again because the sockets don't seem to close even after an hour