Catch ALL requests by LUA-script

andiL nginx-forum at
Tue Mar 1 12:53:11 MSK 2011

Thanks for your answer.

I just figured out, that "location ~ { ...}" will catch all requests,
too ... but i don't know if it's realy that reliable, so the new feature
of the nginx-lua-plugin seems to be the perfect solution for my problem
(thanks again :-) )

Being able to have direct access by lua in the server/http blocks is
great for global actions on the requests.

I just have one more question:

What would be the best phase-handler to check/manipulate http-requests
and http-responses?

LUA can work with rewrite (URI transformation on location level), access
(access restrictions check), content (generating content for output) and
 - as i understand - these are processed by nginx in this given order.

Theoretically the best would be to get in directly in the begining with
rewrite_by_lua(_file) to be able to check/manipulate request-headers,
request-body, etc.?

But nginx will still output it's "default content" after that...
Is there any chance LUA can have access to all of the HTTP-Response, too
(especially the headers - the content is not that important at the

I know that it can be done via ngx.headers["HEADER"] but i don't think
this will be possible when still working in the rewrite/access phase?

Hope i don't understand something very wrong there :)

Thanks, Andi

Posted at Nginx Forum:,179364,179398#msg-179398

More information about the nginx mailing list