diff --git a/bat/openresty-start.bat b/bat/openresty-start.bat index b69a196..a869975 100644 --- a/bat/openresty-start.bat +++ b/bat/openresty-start.bat @@ -4,10 +4,10 @@ rem 启动标志 flag=0 表示之前已经启动 flag=1 表示现在立即启 set flag=0 rem 设置 openresty/nginx的安装目录 -set installPath=D:\work\OpenResty\openresty-1.27.1.2-win64 +set installPath=D:\work\OpenResty\openresty-1.27.1.2-win32 rem 设置 Nginx 项目的工作目录 -set projectPath=D:\OpenrestyPro\AuthService +set projectPath=D:\OpenrestyPro\AuthPlatform rem 设置 项目的配置文件 set PROJECT_CONF=nginx.conf diff --git a/conf/nginx.conf b/conf/nginx.conf index 819e130..114a1d3 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,62 +1,29 @@ -worker_processes 2; -error_log logs/error.log info; +worker_processes 1; + +worker_rlimit_nofile 65535; + events { - worker_connections 1024; + worker_connections 1024; } http { + include mime.types; default_type application/octet-stream; - access_log logs/access.log; - lua_package_path 'src/share/?.lua;;'; #lua 模块 - lua_package_cpath "src/share/lib/?.so;;"; #c模块 - ##include lua.conf; #导入自定义lua配置文件 - ##resolver 8.8.8.8; - lua_shared_dict share_mem_cache 10m; ##共享内存大小 - lua_shared_dict routes_cache 10m; ##路由内存大小 + sendfile on; + keepalive_timeout 65; + limit_req_zone $binary_remote_addr zone=one:50m rate=20r/s; + + lua_package_path 'D:/ZeroBraneStudio-1.90/lualibs/?/?.lua;D:/ZeroBraneStudio-1.90/lualibs/?.lua;;'; + lua_package_cpath 'D:/ZeroBraneStudio-1.90/bin/clibs/?.dll;;'; server { - listen 9090; + listen 9080; server_name localhost; default_type text/html; - location = /favicon.ico { - log_not_found off; - access_log off; + + location /test { + default_type 'text/plain'; + content_by_lua_file 'src/test.lua'; } - - location /api { - content_by_lua_file src/api/api.lua; - } - - #location ^~ /api/ { - # rewrite_by_lua_block { - # local uri = ngx.var.uri - # if string.match(uri, "^/api/v1/") then - # ngx.req.set_uri("/api_v1") - # elseif string.match(uri, "^/api/v2/") then - # ngx.req.set_uri("/api_v2") - # end - # } - #} - - #location /api_v1 { - # content_by_lua_file conf/lua/api_v1.lua; - #} - - #location /api_v2 { - # content_by_lua_file conf/lua/api_v2.lua; - #} - - # 动态路由处理 - #location /router { - # access_by_lua_file "src/routes/dynamic_router.lua"; - # proxy_pass $target; - # proxy_set_header Host $host; - # proxy_set_header X-Real-IP $remote_addr; - #} - - # 路由更新接口 - #location /update-routes { - # content_by_lua_file "src/routes/route_updater.lua"; - #} } -} +} \ No newline at end of file diff --git a/logs/nginx.pid b/logs/nginx.pid index 70f822b..152873e 100644 --- a/logs/nginx.pid +++ b/logs/nginx.pid @@ -1 +1 @@ -12764 +11428 diff --git a/src/api/api.lua b/src/api/api.lua new file mode 100644 index 0000000..75453c0 --- /dev/null +++ b/src/api/api.lua @@ -0,0 +1,27 @@ +--- +--- Generated by EmmyLua(https://github.com/EmmyLua) +--- Created by admin. +--- DateTime: 2025/9/25 14:19 +--- + +local function say_hello(req) + ngx.say("Hello, World!") +end + +local routes = { + ["/hello"] = say_hello, +} + +local function handle_request() + local uri = ngx.var.request_uri + ngx.say("url: " .. uri) + local handler = routes[uri] + if handler then + handler(ngx.req) + else + ngx.status = 404 + ngx.say("Not Found") + end +end + +handle_request() \ No newline at end of file