Nginx+Lua实现POST参数篡改并代理到第三方

本文介绍了如何利用Nginx结合Lua脚本实现对POST请求参数的篡改,并将修改后的请求代理到第三方服务器的技术细节。重点在于配置文件vhost_x.conf和lua脚本wechat_reset_args_access.lua的应用。
摘要由CSDN通过智能技术生成

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
  • 0
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值