```
#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;
}
}
}
```