首页 > Web开发 > 详细

【原创】大叔经验分享(77)openresty(nginx+lua)发http请求

时间:2019-07-29 21:16:07      阅读:154      评论:0      收藏:0      [点我收藏+]

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

 

【原创】大叔经验分享(77)openresty(nginx+lua)发http请求

原文:https://www.cnblogs.com/barneywill/p/11266333.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!