openresty(nginx+lua)发http请求
利用location+proxy_pass间接实现
location ^~ /test/http { internal; proxy_pass http://test.com/path; }
lua代码
local res, err = ngx.location.capture("/test/http", { method = ngx.HTTP_POST, body = body }); if res then ngx.log(ngx.INFO, "response:"..res.body) else ngx.log(ngx.INFO, "error:"..err) end