Welcome! Log In Create A New Profile

Advanced

Re: Catch ALL requests by LUA-script

agentzh
March 01, 2011 06:14AM
On Tue, Mar 1, 2011 at 5:53 PM, andiL <nginx-forum@nginx.us> wrote:
> Thanks for your answer.
>
> I just figured out, that "location ~ { ...}" will catch all requests,
> too

Once a location gets matched, it'll be difficult to persuade nginx to
match against other locations because a hit is already made.

>
> 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.
>

Another difference between rewrite phase handlers and access phase
handlers is that access phase is skipped completely for subrequests
while rewrite phase handlers will be run even in a subrequest.

> 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.?
>

access_by_lua(_file) is fine too :)

> But nginx will still output it's "default content" after that...

Sure.

> 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
> moment)?
>

This is exactly what output filters are for ;)

For now, ngx_lua does not provide output filter hooks like
output_header_filter_by_lua(_file) and
output_body_filter_by_lua(_file). But these are on our TODO list. And
as always: patches welcome, and volunteers welcome!

> 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?
>

No, the rewrite and access phases are just too early :)

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

Almost right :)

Cheers,
-agentzh

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Catch ALL requests by LUA-script

andiL March 01, 2011 02:34AM

Re: Catch ALL requests by LUA-script

agentzh March 01, 2011 03:42AM

Re: Catch ALL requests by LUA-script

andiL March 01, 2011 04:53AM

Re: Catch ALL requests by LUA-script

agentzh March 01, 2011 06:14AM

Re: Catch ALL requests by LUA-script

andiL March 01, 2011 07:52AM

Re: Catch ALL requests by LUA-script

HowToMeetLadies May 02, 2011 12:11AM

Re: Catch ALL requests by LUA-script

agentzh May 03, 2011 10:56PM

Re: Catch ALL requests by LUA-script

HowToMeetLadies May 04, 2011 08:05PM

Re: Catch ALL requests by LUA-script

HowToMeetLadies May 05, 2011 12:29PM

Re: Catch ALL requests by LUA-script

agentzh May 04, 2011 11:22PM

Re: Catch ALL requests by LUA-script

agentzh May 06, 2011 12:28AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 158
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready