nginx下:
location /proxy{
default_type 'text/plain';
lua_code_cache off;
set $appid '';//从lua里重写
set_by_lua_file $url '/home/cq/share/xyx/nginx_example/nginx_server/lua/proxy.lua';
#echo "url = $url";//从lua里赋值得到的url
proxy_pass $url;
}
lua下:
local a = ngx.var.arg_a;
local b = ngx.var.arg_b;
local c = ngx.var.arg_c;
ngx.header.content_type="text/plain";
ngx.var.appid = a;//写入到外部参数里
local uri = "https://api.weixin.qq.com/sns/jscode2session?appid="..a.."&secret="..b.."&js_code="..c.."&grant_type=authorization_code";
return uri;