From e2d680cb2a3b52bc0e653b53064463003e571bb9 Mon Sep 17 00:00:00 2001 From: Mr Chen Date: Sat, 18 Nov 2023 02:36:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8F=8D=E5=90=91=E4=BB=A3?= =?UTF-8?q?=E7=90=86=E4=BB=A3=E8=BF=87=E6=9D=A5=E7=9A=84=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/webstats/lua/webstats_common.lua | 4 ++++ plugins/webstats/lua/webstats_log.lua | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/plugins/webstats/lua/webstats_common.lua b/plugins/webstats/lua/webstats_common.lua index 5ebaa9fa5..d1dd62cd6 100644 --- a/plugins/webstats/lua/webstats_common.lua +++ b/plugins/webstats/lua/webstats_common.lua @@ -121,6 +121,10 @@ end function _M.split(self, str, reps) local arr = {} + -- 修复反向代理代过来的数据 + if "table" == type(data) then + return str + end string.gsub(str,'[^'..reps..']+',function(w) table.insert(arr,w) end) return arr end diff --git a/plugins/webstats/lua/webstats_log.lua b/plugins/webstats/lua/webstats_log.lua index d1f1bfdce..148f3b309 100644 --- a/plugins/webstats/lua/webstats_log.lua +++ b/plugins/webstats/lua/webstats_log.lua @@ -325,6 +325,12 @@ log_by_lua_block { end local remote_addr = ngx.var.remote_addr + + -- 修复反向代理代过来的数据 + if "table" == type(ip_list) then + ip_list = json.encode(ip_list) + end + if not string.find(ip_list, remote_addr) then if remote_addr then ip_list = ip_list .. "," .. remote_addr