Nginx配置导致连接过多 [英] Nginx configuration resulting in too many connections
问题描述
为了实施上传进度模块,以下服务器配置导致打开的文件太多错误
In an attempt to implement the upload progress module, the following server configuration is resulting in too many open files error
2014/11/19 12:10:34 [alert] 31761#0: *1010 socket() failed (24: Too many open files) while connecting to upstream, client: 127.0.0.1, server: xxx, request: "GET /documents/15/edit HTTP/1.0", upstream: "http://127.0.0.1:80/documents/15/edit", host: "127.0.0.1"
2014/11/19 12:10:34 [crit] 31761#0: *1010 open() "/usr/share/nginx/html/50x.html" failed (24: Too many open files), client: 127.0.0.1, server: xxx, request: "GET /documents/15/edit HTTP/1.0", upstream: "http://127.0.0.1:80/documents/15/edit", host: "127.0.0.1"
以下是产生冲突的服务器群的相关部分 passenger_enabled开启; rails_env开发; 根/home/user/app/current/public;
The following is the relevant part of the server bloc which is generating the conflict passenger_enabled on; rails_env development; root /home/user/app/current/public;
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location / {
# proxy to upstream server
proxy_pass http://127.0.0.1;
proxy_redirect default;
# track uploads in the 'proxied' zone
# remember connections for 30s after they finished
track_uploads proxied 30s;
}
location ^~ /progress {
# report uploads tracked in the 'proxied' zone
report_uploads proxied;
}
作为nginx的相对n00b,我不理解这会产生太多文件错误.我认为错误页面仅适用于500-504个服务器错误...
Being a relative n00b to nginx, I do not comprehend where this is generating the too many files error. I assumed that the error pages are only for 500-504 server errors...
推荐答案
首先检查并增加根shell(系统范围内,通常为1024)中打开文件的限制:
First check and increase open files limit in the root shell (system-wide, it is 1024 usually):
# ulimit -n
# ulimit -n 16384
然后,您可以增加nginx的打开文件限制(主上下文,nginx.conf的顶部):
Then you can increase nginx's open files limit (main context, top of nginx.conf):
worker_rlimit_nofile 16384
然后重新启动nginx)
Then restart nginx )
如果这无济于事,请检查更详细的解决方案,例如
If this not help, check more detail solutions like
这篇关于Nginx配置导致连接过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!