Hello,
I have a question about the POST request processing with ngx_lua.
In my case a body of a POST request contains a guess about a backned,
where the request must be processed. So, I need to find this guess
and then process the whole requst without of any modification on
a backend.
So, I've tried to resolve this case with content_by_lua_block. Since
the POST request contains a form with the data, I do
location /bla/bla/bla {
set $backend '';
content_by_lua_block {
local upload = require "resty.upload"
local chunk_size = 4096
local form, err = upload:new(chunk_size)
if not form then
ngx.log(ngx.ERR, "failed to new upload: ", err)
ngx.exit(500)
end
while true do
-- get a header
if typ == "header" then
end
-- ...
-- get a part of the body
if typ == "body" then
-- ...
end
-- check res with ngx.say(res) output and it works
if typ == "eof" then
break
end
end
ngx.var.backend = res
}
proxy_pass http://$backed;
}
At the end of the block I've tried to add ngx.var.backend variable
to expect it right after the content_by_lua_block, but it's empty.
Looks like I did something wrong?
Could you please recommend how can I resolve this case?
Thanks in advance.
--
Sergey A. Osokin