Sub-request using Parent Request Body

agentzh agentzh at gmail.com
Tue Jan 4 06:19:20 MSK 2011


On Tue, Jan 4, 2011 at 10:57 AM, Roman Vasilyev <roman at anchorfree.com> wrote:
> Hello,
>
> I'm trying to make POST analyzer module. To have ability with SPAM detection
> for passing throw traffic, for this I need to have request_body in
> subrequest,  for that I took agentzh / nginx-eval-module
>
> http://forum.nginx.org/read.php?2,84026,84605
>

I don't think it's the right place to look into :)

> and after reading this posts made small changes (please find it below)
> on small tests it working fine, but on something with big POSTs it loosing
> information, could somebody help me with understanding how better fix this.
>

I am afraid you're using ngx_http_read_client_request_body in a wrong
way. When the request body is big enough to exceed the preread part of
the request headers or the network is bad enough, you'll surely loose
data in the request body.

Nginx works in a streaming and non-blocking manner, so you have to
*wait* for the ngx_http_read_client_request_body fully complete (not
just when this function returns but when your ngx_http_stub is called)
before continuing with your rewrite-phase handler. So it's totally
wrong to do nothing in your ngx_http_stub callback. It should be the
key part for your logic.

Please take a peek at the ngx_form_input module to have a live demo for this:

    http://github.com/calio/form-input-nginx-module

It was originally written by one of my intern students and now
maintained by me :)

Good luck!
-agentzh



More information about the nginx mailing list