Nginx Loadbalancer Too Many Open Files

nginx loadbalancer Too many open files

I've added the following line to the nginx.conf:

worker_rlimit_nofile    20000;

Now it works, I don't get any error since the modification.

I hope it will help someone if have the same problem.

nginx forward proxy - failed (24: Too many open files),

I think I found the problem:

here is the nginx error.log

2015/07/09 14:17:27 [error] 15390#0: *7549 connect() failed (111: Connection refused) while connecting to upstream, client: 23.239.194.233, server: , request: "GET http://www.lgqfz.com/ HTTP/1.1", upstream: "http://127.0.0.3:80/", host: "www.lgqfz.com", referrer: "http://www.baidu.com"
2015/07/09 14:17:29 [error] 15390#0: *8121 connect() failed (111: Connection refused) while connecting to upstream, client: 204.44.65.119, server: , request: "GET http://www.lgqfz.com/ HTTP/1.1", upstream: "http://127.0.0.3:80/", host: "www.lgqfz.com", referrer: "http://www.baidu.com"
2015/07/09 14:17:32 [error] 15390#0: *8650 connect() failed (101: Network is unreachable) while connecting to upstream, client: 78.47.53.98, server: , request: "GET http://188.8.253.161/ HTTP/1.1", upstream: "http://188.8.253.161:80/", host: "188.8.253.161", referrer: "http://188.8.253.161/"

It was a DDOS attack on my PROXY that I stopped by allowing only my IP to access the PROXY.

I found it to be common lately - when u crawl a site, and the site identify you as a crawler, it will sometime DDOS attack your proxy until they go black.
One example of such site is amazon.com

10K concurrent connections with nginx

If you see a lot of "Too many open files" errors in your nginx log, it is because you've reach the limit of concurrent open sockets currently set on the server.

You might have to increase the Usage Limit (ULimit) for the nginx user and probably the node app user too. This is the first issue I hit each time I load test an nginx+nodejs. (https://www.cyberciti.biz/faq/linux-unix-nginx-too-many-open-files/)

ULimit

The ulimit command gives you the limits of the current user so you have to run it while connected on the nginx user

# su in the user nginx
su - nginx
ulimit -Hn
ulimit -Sn

# or
su nginx --shell /bin/bash --command "ulimit -Hn"
su nginx --shell /bin/bash --command "ulimit -Sn"

We usually change it in /etc/security/limits.conf

sudo vi /etc/security/limits.conf

# Add the following lines
nginx soft nofile 30000
nginx hard nofile 30000
# Save

# Reload (I think rebooting here is the best way)
sysctl -p

nginx.conf

After that, you have to set the limit at the nginx software level in the nginx config file

sudo vi /etc/nginx/nginx.conf

# Add this line at the root of the config
worker_rlimit_nofile 30000;

# Reload (This will fail if you have SELinux enabled)
sudo nginx -s reload

SELinux

To allow the nginx app to set its own limit you can set a selinux bool:

setsebool httpd_setrlimit on
sudo nginx -s reload

nginx max upload size elasticbeanstalk aws

for anyone who have the same probleme ..
the solution that i found is to put the .conf file in

.platform\nginx\conf.d\elasticbeanstalk/proxy.conf

with content

client_max_body_size 1G; 
proxy_buffering off;
proxy_request_buffering off;

it worked for me



Related Topics



Leave a reply



Submit