```
#user nobody;
#处理进程数,这个配置成和CPU个数一致
worker_processes auto;
#增加worker_cpu_affinity配置参数来充分利用多核cpu
worker_cpu_affinity auto;
#每个处理进程打开的最多文件描述符数目,理论值应该是最多打开文件数(系统的值ulimit -n)与nginx进程数相除,但是nginx分配请求并不均匀,所以建议与ulimit -n的值保持一致
worker_rlimit_nofile 65536;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#error_log logs/error.log warn;
#error_log logs/error.log error;
#指定日志输出位置和级别
error_log logs/error.log error;
#pid logs/nginx.pid;
include modules.conf;
events {
#每个处理进程能并发处理(发起)的最大连接数(包含所有连接数)
worker_connections 655360;
use epoll;
}
http {
client_max_body_size 40m;
include mime.types;
default_type application/octet-stream;
proxy_cache_path /data/amc/nginx/install/cache levels=1:2 keys_zone=cache_html:500m inactive=1d max_size=5000M;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#关闭访问日志
#access_log on;
#access_log logs/access.log main;
#log_format main '[$status] $remote_addr $request |'
#access_log logs/access.log main;
sendfile on;
#支持头部变量名称下划线
underscores_in_headers on;
#tcp_nopush on;
# 20180408 modified by liyu, for EOP performance test
#keepalive_timeout 0;
#前端连接nginx的超时时间
#keepalive_timeout 65;
keepalive_timeout 1200;
keepalive_requests 32768;
#gzip on;
#指定第三方lua文件的扫描路径
lua_package_path "$prefix/lua/lib/?.lua;;";
#定义共享变量,不支持table类型
lua_shared_dict info 16k;
lua_shared_dict snapshot_1 1024k;
lua_shared_dict snapshot_2 1024k;
lua_shared_dict snapshot_3 1024k;
lua_shared_dict stati_data_1 1024k;
lua_shared_dict stati_data_2 1024k;
lua_shared_dict prometheus_metrics 100M;
#上游集群配置
include upstream.conf;
#指定一个连接到代理服务器的超时时间,单位为秒。默认为60秒,最好不要超过75秒
proxy_connect_timeout 60s;
#决定读取后端服务器应答的超时时间,单位为秒。默认为60秒,最好不要超过75秒
proxy_read_timeout 60s;
proxy_send_timeout 60s;
#确定在何种情况下请求将转发到下一个服务器,默认为:error timeout。为了避免重复提交,如果设置为off,后端节点停止掉会部分报错;建议设置为:error
proxy_next_upstream error timeout;
#设置反向代理的头部相关信息
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#nginx启动时处理程序
init_by_lua_file lua/init.lua;
#worker进程启动时处理程序
init_worker_by_lua_file lua/timer.lua;
#请求返回时头部处理程序。独立出一个文件,需要考虑经过多级nginx后的Server的消息,默认Server的值为nginx的版本号
header_filter_by_lua_block {
ngx.header["Server"] = ngx.var.upstream_addr
}
#记录报文明细
body_filter_by_lua_file lua/details.lua;
#日志记录扩展程序
log_by_lua_file lua/logger.lua;
#服务配置
include server.conf;
include server8470.conf;
include server8184.conf;
include server8450.conf;
#include server8550.conf;
#include server8500.conf;
include vhosts/*.conf;
include monit.conf;
server {
listen 8000;
location / {
root html;
index index.html index.htm;
}
}
}
```