I am running a docker with lua-nginx image.
In my Nginx conf file I call the lua script from server { } section:
server {
listen 80;
server_name _;
location /payload {
content_by_lua_file /etc/nginx/handler.lua;
proxy_pass <myUrl>;
}
}
I have an issue that no matter what, after the handler.lua script ends, it will go straight to proxy_pass. Even when lua script says ngx.close !!!
if method == "POST" then
--do some stuff
else
ngx.log(ngx.ERR, "wrong event request method: ", ngx.req.get_method())
return ngx.exit (ngx.HTTP_NOT_ACCEPTABLE)
end
So when I do a GET request, after the "return ngx.exit()", the nginx.config will continue to the proxy_pass.
This makes my lua code meaningless. I want to have proxy_pass only if the method is POST.