1

Looking for scaling Eclipse Che (a cloud IDE), I'm implementing a Che Farm. In short, a group of Eclipse Che instances behind a reverse proxy.

enter image description here

Ok, I'm implementing the reverse proxy using Nginx on an EC2 instance using Amazon Linux AMI, but I found this problem: Eclipse Che needs opened the port 8080 for the client and the range 32768-65535 for its workspaces (more info here).

So, I modified the nginx.conf file like this:

server {
    listen 32768;
    listen 32769;
    listen 32770;
    listen 32771;
    [...]
    listen 65534;
    listen 65535;

    server_name  http://eclipse.company.cxx;

    location / {
        proxy_pass  http://eclipse.company.local:$server_port;
    }
}

After restart nginx, I got this message:

$ sudo service nginx restart
nginx: [emerg] socket() 0.0.0.0:33786 failed (24: Too many open files)
nginx: configuration file /etc/nginx/nginx.conf test failed

Two questions, please:

  1. Is this a valid approach for implement a reverse proxy in this situation?
  2. If this is valid, how can I fix the error "Too many open files"?
1
  • Not sure about your environment, just as a hint: Is the machine in question publicly reachable? If so, implement authentication / authorization, or use a VPN.

    If this is valid, how can I fix the error "Too many open files"?

  • Probably, because it's listening to that many ports, your nginx, runs against limits, specifically the ones dealing with file descriptor(s), which "[...] is an abstract indicator (handle) used to access a file or other input/output resource, such as a pipe or network socket [...]".

  • To tune these limits:

    • Leverage the nginx directive worker_rlimit_nofile.
    • If this is not enough:

      • Change the system wide limit, which is stored in /proc/sys/file-max. To alter it run sysctl -w fs.file-max=${your-new-limit}. To make it persistent across reboots etc. edit /etc/sysctl.conf.
      • Change the user limit, which is stored in /etc/security/limits.conf: Inside there, put for example two lines reading:

        nginx soft nofile ${your-new-soft-limit} 
        nginx hard nofile ${your-new-hard-limit}
        

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.