/etc/security/limits.conf
#<user>     <type>    <item>     <value>
*           soft      nofile     1048576
*           hard      nofile     1048576
root        soft      nofile     1048576
root        hard      nofile     1048576 


/etc/sysctl.conf
net.ipv4.ip_local_port_range = 12000 65535
fs.file-max = 1048576



ps auxf | grep nginx
cat /proc/1167/limits | grep "open files"


nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
worker_rlimit_nofile 1048576;    

events {
        worker_connections 8000;
        multi_accept on;
}

http {

        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 65;
        types_hash_max_size 2048;
        server_tokens off;
