Welcome! Log In Create A New Profile

Advanced

Re: architecture of a module - processing a response from a subrequest

Piotr Sikora
July 29, 2010 05:46AM
Hi,

> 2. from this original request, create a POST sub request to another
> server.
>
> - seems to work. I use a sub-request to '/foo' and added a location
> '/foo' which do a proxy_pass to http://foo/.
>
> Question: Can I do this without touching the nginx.conf? I would like to
> specify the IP/port of the subrequest in my handler and _not_ add a
> special location to nginx.conf

Just check what "proxy_pass" directive does in the configuration phase and
copy that behavior.

> 3. read the whole response from this sub request into memory
>
> Question: What is the recommended way to read and process the response
> body of a sub request which shouldn't go to the client? Should I use a
> body-filter or can I access the response body from my post-subrequest
> handler. I tried the later but it does not work. Any example code?

Check eval module [1].

> 4. modify the original request (header and possibly body) depending on
> the data from the sub request
>
> 5. send the new main request upstream
>
> - I assume that I simply should modify the request and return a
> DECLINED to let the next handler do the work.
>
> 6. intercept the response, do a second subrequest and modify the response
>
> - should probably done in a filter?

What exactly are you trying to achieve? Maybe you could use
X-Accel-Redirect, eval module or ngx_lua [2] instead?

> Another question: I want to intercept ALL requests to nginx. Which phase
> would you recommend for my handler? How can I assure, that I'm the first
> handler in the chain?

There is only one active content handler at the time. Unless you want to
skip all other phases (rewrite, access, etc), which probably isn't a good
idea.

[1] http://github.com/vkholodkov/nginx-eval-module
[2] http://github.com/chaoslawful/lua-nginx-module

Best regards,
Piotr Sikora < piotr.sikora@frickle.com >



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

architecture of a module - processing a response from a subrequest

Mirko Dziadzka 3802 July 29, 2010 04:12AM

Re: architecture of a module - processing a response from a subrequest

Piotr Sikora 936 July 29, 2010 05:46AM

Re: architecture of a module - processing a response from a subrequest

Mirko Dziadzka 904 July 29, 2010 07:06AM

Re: architecture of a module - processing a response from a subrequest

agentzh 1664 August 04, 2010 10:28PM

Re: architecture of a module - processing a response from a subrequest

Mirko Dziadzka 967 July 29, 2010 10:04AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 91
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready