Nginx+Lua实现POST参数篡改并代理到第三方
vhost_x.conf
server {
listen 80;
server_name proxy-wechat.gitv.we;
lua_code_cache on;
access_log logs/proxy-wechat.gitv.we.access.log gitv;
error_log logs/proxy-wechat.gitv.we.error.log;
resolver xxx.xxx.15.112;
location ~ /wxwarning {
lua_need_request_body on;
#access_by_lua '
# local cjson = require "cjson";
# local req_body = ngx.req.get_body_data() or "-";
# post_data = cjson.decode(req_body);
# post_data.appid = 100;
# ngx.req.set_body_data(cjson.encode(post_data));
# --ngx.say(post_data.appid);
#';
access_by_lua_file "/opt/soft/nginx/lua/wechat_reset_args_access.lua";
set $wechat_url "wechat.gitv.we/gitv/notify";
proxy_pass http://$wechat_url;
}
}
–wechat_reset_args_access.lua
function reset_post_body()
--Nginx服务器中使用lua获取get或post参数
--[[