【原創】大叔經驗分享(77)openresty(nginx+lua)發http請求

openresty(nginx+lua)發http請求nginx

利用location+proxy_pass間接實現lua

    location ^~ /test/http {
        internal;
        proxy_pass http://test.com/path;
    }

lua代碼spa

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
相關文章
相關標籤/搜索