chaoslawful/lua-nginx-module — Issue #88: Redirect request based on Post args
Author: xianlinbox
Created: 2012-03-05 11:57:06+00:00
State: open

Hi All

I have a requirement which need parse the post data body, then redirect the request based on one argument. I used
the following scripts to implement it.

location = /post {
content_by_lua '
ngx.req.read_body()
local args = ngx.req.get_post_args()
for key, val in pairs(args) do
ngx.say(key)
if key == "arg1" then
ngx.redirect(/val)
end
end
';
}

But this didn't work, I'm sorry i can't give the nginx.conf and error.log(I open the nginx debug module) because of the limit of company network......

in the error.log, I can't see any content of "ngx.say(key)". is it "log the key into error.log"?

Could you give me some advices how to parse the args in HTTP post data body? Thanks!!

Sincerely
Lincoln