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

 

相关文章:

  • 2021-10-12
  • 2021-12-28
  • 2021-12-14
  • 2021-08-02
  • 2021-12-01
  • 2022-03-08
  • 2021-12-30
  • 2021-07-06
猜你喜欢
  • 2021-10-26
  • 2021-06-06
  • 2021-09-01
  • 2021-12-20
  • 2022-02-28
  • 2021-09-26
  • 2021-07-18
相关资源
相似解决方案