From 58d69d734df44580bbc9bee6128aec4a9b4f283a Mon Sep 17 00:00:00 2001 From: midoks Date: Sat, 7 Jan 2023 00:15:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E3=80=90=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E3=80=91=E5=BC=BA=E5=88=B6=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=97=A5=E5=BF=97POST=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/openresty/conf/nginx.conf | 1 + plugins/webstats/conf/webstats.conf | 1 + plugins/webstats/index.py | 26 ++++++++++++++++++++++++++ 3 files changed, 28 insertions(+) diff --git a/plugins/openresty/conf/nginx.conf b/plugins/openresty/conf/nginx.conf index a08233d44..674cbd862 100644 --- a/plugins/openresty/conf/nginx.conf +++ b/plugins/openresty/conf/nginx.conf @@ -28,6 +28,7 @@ http server_names_hash_bucket_size 512; client_header_buffer_size 32k; large_client_header_buffers 4 32k; + client_body_buffer_size 50m; client_max_body_size 50m; sendfile on; diff --git a/plugins/webstats/conf/webstats.conf b/plugins/webstats/conf/webstats.conf index 6e4c6e0d9..5b3277ea2 100644 --- a/plugins/webstats/conf/webstats.conf +++ b/plugins/webstats/conf/webstats.conf @@ -1,2 +1,3 @@ lua_shared_dict mw_total 100m; +lua_need_request_body off; include {$SERVER_APP}/lua/webstats_log.lua; \ No newline at end of file diff --git a/plugins/webstats/index.py b/plugins/webstats/index.py index 784a555c6..9ec2279ea 100755 --- a/plugins/webstats/index.py +++ b/plugins/webstats/index.py @@ -5,6 +5,7 @@ import io import os import time import json +import re sys.path.append(os.getcwd() + "/class/core") import mw @@ -292,6 +293,22 @@ def getGlobalConf(): return mw.returnJson(True, 'ok', content) +def openLuaNeedRequestBody(): + conf = luaConf() + content = mw.readFile(conf) + content = re.sub("lua_need_request_body (.*);", + 'lua_need_request_body on;', content) + mw.writeFile(conf, content) + + +def closeLuaNeedRequestBody(): + conf = luaConf() + content = mw.readFile(conf) + content = re.sub("lua_need_request_body (.*);", + 'lua_need_request_body off;', content) + mw.writeFile(conf, content) + + def setGlobalConf(): args = getArgs() @@ -299,14 +316,23 @@ def setGlobalConf(): content = mw.readFile(conf) content = json.loads(content) + open_force_get_request_body = False for v in ['record_post_args', 'record_get_403_args']: data = checkArgs(args, [v]) if data[0]: rval = False if args[v] == "true": rval = True + open_force_get_request_body = True + content['global'][v] = rval + # 开启强制获取日志配置 + if open_force_get_request_body: + openLuaNeedRequestBody() + else: + closeLuaNeedRequestBody() + for v in ['ip_top_num', 'uri_top_num', 'save_day']: data = checkArgs(args, [v]) if data[0]: