This commit is contained in:
dami
2026-07-02 14:22:10 +08:00
parent 7b5f1a4253
commit f26e8bc520
2 changed files with 8 additions and 22 deletions
+8 -7
View File
@@ -59,6 +59,9 @@ local flow_column = "flow" .. number_day
-- 日志文件存储目录
local log_dir = "{$SERVER_APP}/logs"
-- 当前站点的配置(模块级变量,供多个函数共享)
local auto_config = nil
--[[
创建模块实例
@return table 模块实例对象
@@ -160,7 +163,6 @@ end
]]
function _M.setInputSn(self, input_sn)
local global_config = config["global"]
local auto_config
if config[input_sn] == nil then
auto_config = global_config
else
@@ -1237,14 +1239,13 @@ end
function _M.get_client_ip(self)
local client_ip = "unknown"
local cdn = auto_config['cdn']
local request_header = ngx.req.get_headers()
if cdn == true then
for _,v in ipairs(auto_config['cdn_headers']) do
if auto_config and auto_config['cdn'] == true then
local request_header = ngx.req.get_headers()
for _, v in ipairs(auto_config['cdn_headers'] or {}) do
if request_header[v] ~= nil and request_header[v] ~= "" then
local ip_list = request_header[v]
client_ip = self:split(ip_list,',')[1]
break;
client_ip = self:split(ip_list, ',')[1]
break
end
end
end
-15
View File
@@ -226,21 +226,6 @@ log_by_lua_block {
return cache:get("global_exclude_ip_" .. ip) ~= nil
end
--[[
状态码过滤表
需要记录详细信息的状态码(4xx 和 5xx 错误)
]]
local status_codes_to_log = {
["400"] = true, ["401"] = true, ["402"] = true, ["403"] = true, ["404"] = true,
["405"] = true, ["406"] = true, ["407"] = true, ["408"] = true, ["409"] = true,
["410"] = true, ["411"] = true, ["412"] = true, ["413"] = true, ["414"] = true,
["415"] = true, ["416"] = true, ["417"] = true, ["418"] = true, ["421"] = true,
["422"] = true, ["423"] = true, ["424"] = true, ["425"] = true, ["426"] = true,
["449"] = true, ["451"] = true, ["499"] = true, ["500"] = true, ["501"] = true,
["502"] = true, ["503"] = true, ["504"] = true, ["505"] = true, ["506"] = true,
["507"] = true, ["509"] = true, ["510"] = true
}
--[[
日志采集函数
采集请求数据,识别爬虫/客户端,计算统计指标,然后入队