nginx version: openresty/1.21.4.2 使用yum方式安装
worker_processes 1;
error_log logs/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
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 logs/access.log main;
error_log logs/error.log;
sendfile on;
keepalive_timeout 65;
lua_code_cache off;
lua_package_path "/usr/local/openresty/nginx/conf/modules/?.lua;/usr/local/openresty/lualib/resty/?.lua;/usr/local/openresty/lualib/?.lua;;/usr/local/lib/luarocks/rocks-5.1/share/lua/5.1/?.lua;;/usr/local/openresty/lualib/resty/?.lua;;";
lua_package_cpath "/usr/local/lib/luarocks/rocks-5.1/lib/?.so;;";
lua_shared_dict sites 10m;
init_by_lua 'ngx.log(ngx.ERR, "开始init") ';
server {
listen 9999; # 监听 9999 端口
server_name _; # 可以根据实际需求设置 server_name
location /redis/ {
access_by_lua 'ngx.log(ngx.INFO, "开始执行lua")';
return 200;
}
access_log logs/access.log main;
error_log logs/error.log;
}
}
http中init的lua可以打印日志,server的不行,什么错误都没有报