worker_processes 2; error_log logs/error.log info; events { worker_connections 1024; } http { 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; ##路由内存大小 server { listen 9090; server_name localhost; default_type text/html; location = /favicon.ico { log_not_found off; access_log off; } 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"; #} } }