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