0

I'm running Ubuntu Server. This is what I've done:

/etc/security/limits.conf:

*               soft    nofile          10240
*               hard    nofile          10240

And added in /etc/pam.d/common-session:

session required pam_limits.so

And nginx conf itself /etc/nginx/nginx.conf

user www-data;
worker_processes 1; #I have only 1 core
pid /run/nginx.pid;

events {
    worker_connections 10240;
    # multi_accept on;
}

worker_rlimit_nofile 10240;

But trying to confirm changes:

root@ubuntu_ngix:~# ulimit -Hn
4096
root@ubuntu_ngix:~# ulimit -Sn
1024

I have restart nginx and also my server, but still nothing. What am I doing wrong here?

I'm running nginx as www-data user.

Badr Hari
  • 163
  • 2
  • 11

2 Answers2

1

The config /etc/security/limits.conf is specific to PAM. PAM, in general, is not used by software that manages services such as nginx.

So everything from init, to upstart, to systemd do not use the limits.conf at all.

nginx has a specific configuration setting for increasing the file descriptor limit worker_rlimit_nofile.

Outside of all configuration blocks (not in http or a server) add:

worker_rlimit_nofile 10240
h0tw1r3
  • 2,776
  • 19
  • 17
0

Check the permissions of /etc/security/limits.conf. It should be world readable (mode 0644).

I've spent many moons trying to figure out why limits won't take effect before.

drew
  • 173
  • 1
  • 6