Reading body during the REWRITE phase ?
serg.brester at sebres.de
Fri Jan 15 15:04:17 UTC 2016
It's normally no proper way to read a body within REWRITE phase (I think
you mean body of something like POST request).
The request body will be typically read resp. upstreamed first if
location will be processed (after all of the phases, including a rewrite
But you can use that inside another location using some modules, that
may read a body (even manipulate it for example inside a filter) and
then upstream it further to another location.
For example see the nginx-upload-module , that read
multipart/form-data, disaggregates all parts with file-data (writes such
parts in files), and hereafter passes modified request body (even
without file-data) to another location... The similar things will do the
You can also overwrite some default filter handlers, to read the body
formerly, but it would be not really nginx-way (you know, everything
should be be asynchronously =).
BTW, if you use "auth_request" (and other things internally using
sub_request) you can disable passing of the body inside a location that
do auth_request (not in main location), with directives like
"scgi_pass_request_body off;", "fastcgi_pass_request_body off;", etc.
Hope it helps reasonably...
Am 15.01.2016 15:01, schrieb Thibault Koechlin:
> I have a module (naxsi) that reads the body during the REWRITE phase, in
> the exact same way that ngx_form_input does :
> https://github.com/calio/form-input-nginx-module .
> When used with auth_request (or maybe other modules, but that's the
> first time I encounter this issue within a few years of usage), there is
> no request made to the upstream if the request is made using POST/PUT
> and the body is bigger than client_body_buffer_size.
> For the simplicity of the example, we'll assume I'm talking about
> ngx_form_input (behaviour is the same, except code is way shorter).
> The user reporting me the bug opened a ticket :
> https://trac.nginx.org/nginx/ticket/801 . It is possible to replace naxsi
> with ngx_for_input and obtain the same results.
> From Maxim's reply, it seems I failed to properly restore request
> handlers after reading body.
> What would be (if there is any) the proper way to read body within
> REWRITE phase ? Is there any example/existing module that does such so I
> can understand what am I doing wrong ? (In the past, I always thought
> ngx_form_input was the reference one).
> PS: You can find a bit more details here :
> https://github.com/nbs-system/naxsi/issues/226  (including sample config
> & commands to reproduce bug)
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel 
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the nginx-devel