# 原生信息屏蔽
## 修改body_filter.lua
local cjson = require("cjson")
local cjson2 = cjson.new()
local resp,eof = ngx.arg[1],ngx.arg[2]
ptn="(java\\.lang\\.*)|(xception)|(error)|(Error)|(JSONObject)|(unexpected[%s]?error)|(too[%s]many[%s]values[%s]to[%s]unpack)|(NoneType)"
if resp ~= "" and not ngx.is_subrequest then
if pcall(cjson.decode,resp) then
ngx.log(ngx.ERR,"[resp_data_type]:", type(resp),"[resp_data]:", resp,"[eof]:", eof)
local t = cjson.decode(resp)
if t.code and t.code ~= 200 and t.msg then
local m, err = ngx.re.match(t.msg, ptn, "jo")
if m then
t.msg = 'request failed'
end
end
end
## nginx配置返回信息过滤
body_filter_by_lua_file /etc/nginx/conf.d/body_filter.lua;
## nginx配置屏蔽内容长度
header_filter_by_lua 'ngx.header.content_length = nil';