worker_processes auto; #默认是1,通常设置为CPU 个数,如不清楚,可设为auto.
worker_connections 10240; #默认值是1024,单个worker进程处理最大连接数.
keepalive_requests 128; #单个持久连接最大发送请求数,默认100
keepalive_timeout 60; #空闲持久连接超时时间
keepalive 32; #upstream持久连接
proxy_http_version 1.1;
proxy_set_header Connection "";
sendfile on;
缓存:
location ~* \.(jpg|jpeg|png|gif|ico|js|htm|html)$ {
expires 10d;
}
开启压缩
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
关闭access日志打印
http {
access_log off;
}
nofile and nproc 设置为合理的值, 修改/etc/security/limits.conf
myuser - nofile 10240
myuser - nproc 10240
修改kernel参数
net.ipv4.ip_local_port_range = 32768 60999
net.ipv4.tcp_fin_timeout = 60
net.ipv4.tcp_tw_reuse = 1 #TCP连接重用
net.core.somaxconn = 256 #该项设置等待被Nginx接受的连接的排队大小