# nginx.conf
http {
...
...
lua_shared_dict statics_dict 1M; # 初始化变量
lua_package_path "/etc/nginx/ngx_lua_reqstatus/?.lua"; #路径
log_by_lua_file "/etc/nginx/ngx_lua_reqstatus/hook.lua"; # 添加此句
server {
listen 80;
server_name www.justforfun.com;
location /{
...
}
}
# http 接口
server {
listen 127.0.0.1:6080;
location /{
access_by_lua_file "/etc/nginx/ngx_lua_reqstatus/status.lua";
}
}
}
查看 www.justforfun.com
的运行状况:
curl localhost:6080/?domain=www.justforfun.com
输出
Server Name key: www.justforfun.com
Seconds SinceLast: 26.601999998093
Average Req Time Sec: 0.031799983978271
Request Count: 5
Requests Per Secs: 0.18795579281101
5xx num: 0