location / {
set $bindip '';
content_by_lua_file '/usr/local/nginx/lua/proxy.lua';
}
location /proxy {
proxy_pass "http://$host$request_uri";
proxy_bind $bindip;
}
local action = ngx.var.request_method
if action == "POST" then
method = ngx.HTTP_POST
else
method = ngx.HTTP_GET
end
res = ngx.location.capture(
'/proxy', { method = method, always_forward_body = true, copy_all_vars = true }
)
ngx.print(res.body)
ngx.print(res.status)
标签:none