2025-10-17 10:16:13 +08:00
|
|
|
|
worker_processes auto; #nginx worker 数量
|
2025-10-17 15:43:19 +08:00
|
|
|
|
error_log /home/frankly/work/AuthPlatform/logs/error.log info; #指定错误日志文件路径
|
2025-09-27 15:14:13 +08:00
|
|
|
|
|
2025-09-27 23:43:35 +08:00
|
|
|
|
#worker_rlimit_nofile 65535;
|
2025-09-27 15:14:13 +08:00
|
|
|
|
|
2025-09-25 13:56:33 +08:00
|
|
|
|
events {
|
2025-09-27 15:14:13 +08:00
|
|
|
|
worker_connections 1024;
|
2025-09-25 13:56:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
http {
|
2025-10-31 15:09:03 +08:00
|
|
|
|
|
2025-10-17 15:43:19 +08:00
|
|
|
|
##lua_need_request_body on; #开启读取请求体数据
|
|
|
|
|
|
client_max_body_size 1024M; #允许最大100k的请求体
|
|
|
|
|
|
client_body_buffer_size 1024M; #设置缓冲区大小
|
2025-10-17 10:16:13 +08:00
|
|
|
|
|
2025-11-04 09:33:40 +08:00
|
|
|
|
#lua_code_cache off; #关闭代码缓存,修改lua脚本不需要重启
|
|
|
|
|
|
|
2025-10-31 15:09:03 +08:00
|
|
|
|
lua_package_path '$prefix/src/?/?.lua;$prefix/src/?.lua;/home/frankly/work/AuthPlatform/src/?/?.lua;/home/frankly/work/AuthPlatform/src/?.lua;;';
|
2025-11-04 09:33:40 +08:00
|
|
|
|
lua_package_cpath '$prefix/src/share/lib/?.so;/home/frankly/work/AuthPlatform/src/share/lib/?.so;;';
|
2025-09-25 13:56:33 +08:00
|
|
|
|
|
2025-10-14 14:45:47 +08:00
|
|
|
|
# Path of the file with trusted CA certificates.
|
|
|
|
|
|
#lua_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;
|
|
|
|
|
|
|
|
|
|
|
|
# The verification depth in the server certificates chain.
|
|
|
|
|
|
#lua_ssl_verify_depth 3;
|
|
|
|
|
|
|
2025-11-04 21:57:42 +08:00
|
|
|
|
#在Nginx启动时执行的Lua代码块
|
2025-11-05 16:17:17 +08:00
|
|
|
|
#初始化用户角色权限相关的共享内存
|
2025-11-06 11:51:06 +08:00
|
|
|
|
lua_shared_dict dict 10m;
|
2025-11-05 16:17:17 +08:00
|
|
|
|
#init_by_lua_block {
|
|
|
|
|
|
# -- 定义一个全局变量
|
|
|
|
|
|
# ngx.log(ngx.INFO, "Initializing global variable")
|
|
|
|
|
|
# global_var = "Hello, Nginx with Lua!"
|
|
|
|
|
|
# -- 初始化一个共享字典(需要 lua-shared-dict 模块)
|
|
|
|
|
|
# local shared_dict = ngx.shared.dict_a
|
|
|
|
|
|
# shared_dict:set("key", "value")
|
|
|
|
|
|
#}
|
2025-11-04 21:57:42 +08:00
|
|
|
|
#init_by_lua_block 与 init_by_lua_file 只能初始化其中的一个,不能同时启用
|
|
|
|
|
|
#否则报错nginx: [emerg] "init_by_lua_file" directive is duplicate
|
2025-11-06 11:51:06 +08:00
|
|
|
|
#init_by_lua_file '/home/frankly/work/AuthPlatform/src/init.lua';
|
|
|
|
|
|
|
|
|
|
|
|
init_worker_by_lua_file '/home/frankly/work/AuthPlatform/src/init.lua';
|
2025-11-04 09:33:40 +08:00
|
|
|
|
|
2025-09-25 13:56:33 +08:00
|
|
|
|
server {
|
2025-09-27 15:14:13 +08:00
|
|
|
|
listen 9080;
|
2025-09-27 23:43:35 +08:00
|
|
|
|
server_name 127.0.0.1;
|
2025-09-25 13:56:33 +08:00
|
|
|
|
default_type text/html;
|
2025-09-27 23:43:35 +08:00
|
|
|
|
location = /favicon.ico {
|
|
|
|
|
|
log_not_found off;
|
|
|
|
|
|
access_log off;
|
|
|
|
|
|
}
|
2025-11-01 15:38:37 +08:00
|
|
|
|
## 应用路径 todo 路径问题
|
2025-10-30 20:37:03 +08:00
|
|
|
|
set $APP_PATH '/home/frankly/work/AuthPlatform';
|
2025-10-31 15:09:03 +08:00
|
|
|
|
|
2025-11-10 09:58:24 +08:00
|
|
|
|
#访问时允许跨域处理
|
|
|
|
|
|
access_by_lua_block {
|
|
|
|
|
|
ngx.header["Access-Control-Allow-Origin"] = "*"
|
|
|
|
|
|
ngx.header["Access-Control-Allow-Methods"] = "GET, POST, DELETE, PUT"
|
|
|
|
|
|
ngx.header["Access-Control-Allow-Headers"] = "Content-Type, Authorization"
|
|
|
|
|
|
if ngx.var.request_method == "OPTIONS" then
|
|
|
|
|
|
ngx.exit(ngx.HTTP_NOT_ALLOWED)
|
|
|
|
|
|
end
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-10-30 11:30:42 +08:00
|
|
|
|
#数据列表配置
|
2025-10-31 21:32:39 +08:00
|
|
|
|
include 'system/system.conf';
|
2025-10-16 16:47:24 +08:00
|
|
|
|
|
2025-10-30 11:30:42 +08:00
|
|
|
|
#测试接口配置
|
2025-11-07 07:58:29 +08:00
|
|
|
|
location /testTree {
|
|
|
|
|
|
content_by_lua_file '${APP_PATH}/src/test/testRadixtree.lua';
|
2025-10-29 17:29:17 +08:00
|
|
|
|
}
|
2025-11-04 09:33:40 +08:00
|
|
|
|
location /testRBAC {
|
|
|
|
|
|
content_by_lua_file '${APP_PATH}/src/test/testRBAC.lua';
|
|
|
|
|
|
}
|
2025-11-05 16:17:17 +08:00
|
|
|
|
location /test {
|
2025-10-30 20:37:03 +08:00
|
|
|
|
content_by_lua_file '${APP_PATH}/src/test/test.lua';
|
2025-10-29 17:29:17 +08:00
|
|
|
|
}
|
2025-11-04 09:33:40 +08:00
|
|
|
|
location = /testSM {
|
|
|
|
|
|
content_by_lua_block {
|
|
|
|
|
|
cjson = require "cjson.safe"
|
|
|
|
|
|
ngx.say(cjson.encode({a = 1, b = 2}))
|
|
|
|
|
|
local dict_a = ngx.shared.dict_a;
|
|
|
|
|
|
ngx.say("abc=",dict_a:get("abc"))
|
|
|
|
|
|
|
|
|
|
|
|
-- 访问全局变量
|
|
|
|
|
|
ngx.say("Global variable: ", global_var)
|
|
|
|
|
|
|
|
|
|
|
|
-- 访问共享字典
|
|
|
|
|
|
ngx.say("Shared dict value: ", dict_a:get("key"))
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-09-25 13:56:33 +08:00
|
|
|
|
}
|
2025-11-10 08:30:19 +08:00
|
|
|
|
|
2025-11-10 09:58:24 +08:00
|
|
|
|
#server {
|
|
|
|
|
|
# listen 9081 ssl http2;
|
|
|
|
|
|
# server_name *.*;
|
|
|
|
|
|
# ssl_certificate ssl/metroid.crt;
|
|
|
|
|
|
# ssl_certificate_key ssl/metroid.key;
|
|
|
|
|
|
#}
|
2025-09-27 15:14:13 +08:00
|
|
|
|
}
|