【发布时间】:2021-06-06 06:47:23
【问题描述】:
我正在尝试使用 lua-resty-http 模块代理请求。我目前正在为 http 请求传递标头、正文、请求方法和 url,这些都可以正常工作。但是当文件上传发布请求来时它无法这样做,显然我还没有配置它这样做。所以我也想要代理这种类型的请求。这是我到目前为止的代码的快照,我应该进行哪些更改以便提取文件上传数据并使用 lua-resty-http 模块发送它->
local http = require "resty.http"
local cjson = require "cjson"
local httpc = http.new()
local path = ngx.var.request_uri
local passHeader = {["cookie"]=ngx.req.get_headers()["cookie"]}
passHeader["content-type"] = ngx.req.get_headers()["content-type"]
ngx.req.read_body();
body = ngx.req.get_body_data();
local original_req_uri = "https://" .. "fakehost.com" .. path
local req_method = ngx.req.get_method()
local res, err = httpc:request_uri(original_req_uri, {
method = req_method,
ssl_verify = false,
keepalive_timeout = 60000,
headers = passHeader,
keepalive_pool = 10,
body = body
})
【问题讨论】:
标签: file-upload lua proxy http-post openresty