(1)开启status模块
location /status {
stub_status on;#开启status模块
access_log off;#关闭访问日志记录
allow 127.0.0.1;#允许IP访问
allow localhost;
deny all;#拒绝其他IP访问
}
(2)设置并发
worker_processes 2;#启动多少个worker进程
events {
worker_connections 50000;#每个worker进程支持的最大并发连接数量
}
(3)设置最大可打开文件数
worker_rlimit_nofile 65535;
另外,注意linux系统最大文件限制数
vim /etc/security/limits.conf
root hard nofile 65000
root soft nofile 65000
(4)gzip压缩
gzip on;#开启压缩
gzip_min_length 1000;#对大于指定字节大小的文件进行压缩处理
gzip_comp_level 4;#压缩比率
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;#指定需压缩的文件类型
(5)设置缓存
open_file_cache max=2000 inactive=20s;#最大缓存数量,清除指定时间内无请求的缓存
op