diff --git a/conf/nginx.conf b/conf/nginx.conf index 53f3559..9af0994 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -1,4 +1,4 @@ -worker_processes 1; #nginx worker 数量 +worker_processes auto; #nginx worker 数量 error_log logs/error.log; #指定错误日志文件路径 #worker_rlimit_nofile 65535; @@ -8,6 +8,9 @@ events { } http { + client_max_body_size 10k; #允许最大100k的请求体 + client_body_buffer_size 4k; #设置缓冲区大小 + lua_package_path '$prefix/src/?/?.lua;$prefix/src/?.lua;/home/frankly/work/AuthPlatform/src/?.lua;/home/frankly/work/AuthPlatform/src/?/?.lua;;'; lua_package_cpath '$prefix/src/share/lib/?.so;;'; diff --git a/conf/system/test.conf b/conf/system/test.conf index ac50dd7..70ba431 100644 --- a/conf/system/test.conf +++ b/conf/system/test.conf @@ -1,4 +1,8 @@ #测试接口文件 location /testSQL { content_by_lua_file '/home/frankly/work/AuthPlatform/src/test/testPostgres.lua'; +} + +location /cjson { + content_by_lua_file '/home/frankly/work/AuthPlatform/src/test/test.lua'; } \ No newline at end of file diff --git a/src/test/test.lua b/src/test/test.lua index 79aa0ba..d71db47 100644 --- a/src/test/test.lua +++ b/src/test/test.lua @@ -2,4 +2,36 @@ --- Generated by EmmyLua(https://github.com/EmmyLua) --- Created by admin. --- DateTime: 2025/10/15 09:12 ---- \ No newline at end of file +--- + +--读取请求体的数据 +ngx.req.read_body() + +--获取请求数据 +local body_data = ngx.req.get_body_data() + +if not body_data then + ngx.say("read file error:"..err) + return ngx.exit(400) +end + +ngx.say(body_data) + + +--local cjson = require("cjson") +--local file_path = "/home/frankly/work/test.dat" +--local file_length = 1024 * 1024 * 380 +--local f, err = io.input(file_path, "r") +--if not f then +-- ngx.say("read file error:"..err) +-- return +--end +--local content = f:read(file_length) --读取文件内容 +--f:close() --关闭文件 +----ngx.say(content) +--local res = { +-- key = "data", +-- value = content +--} +--ngx.header["Content-Type"] = 'application/json; charset=UTF-8' +--ngx.say(cjson.encode(res)) \ No newline at end of file