增加修改内容
This commit is contained in:
parent
280c6e5cdf
commit
81d224affe
|
@ -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
|
||||
|
|
|
@ -1,62 +1,29 @@
|
|||
worker_processes 2;
|
||||
error_log logs/error.log info;
|
||||
worker_processes 1;
|
||||
|
||||
worker_rlimit_nofile 65535;
|
||||
|
||||
events {
|
||||
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";
|
||||
#}
|
||||
}
|
||||
}
|
|
@ -1 +1 @@
|
|||
12764
|
||||
11428
|
||||
|
|
27
src/api/api.lua
Normal file
27
src/api/api.lua
Normal file
|
@ -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()
|
Loading…
Reference in New Issue
Block a user