diff --git a/nginx/nginx.conf b/nginx/nginx.conf index dfbb1ef..71be6f0 100644 --- a/nginx/nginx.conf +++ b/nginx/nginx.conf @@ -139,6 +139,18 @@ http { ngx.req.read_body() local body = ngx.req.get_body_data() + -- 如果 body 为空,可能是因为请求体被写入了临时文件 + if not body then + local body_file = ngx.req.get_body_file() + if body_file then + local file = io.open(body_file, "r") + if file then + body = file:read("*all") + file:close() + end + end + end + if not body then ngx.status = 400 ngx.say(cjson.encode({error = "Empty body"}))