Sub-request using Parent Request Body

Roman Vasilyev roman at
Wed Jan 5 03:20:07 MSK 2011

On 01/03/2011 10:23 PM, agentzh wrote:
> On Tue, Jan 4, 2011 at 11:51 AM, Roman Vasilyev<roman at>  wrote:
>> This module was from which I begun. Originally I saved all input data into
>> variable and tried to pass it into fastcgi subrequest, unfortunately when
>> I'm passing this variable in subrequest request_body is already empty,
> How did you pass this variable into your subrequest? It looks weird to me :)
Let me show one variant of nginx.conf's:
   location / {
     include proxy.conf;
     eval_subrequest_in_memory off;
     eval_override_content_type text/plain;
     eval $res {
       include spam_fastcgi.conf;
       if ( $request_method = POST) {
         fastcgi_pass   unix:/var/run/nginx/cgiwrap-dispatch.sock;
    if ( $res = SPAM) {
      rewrite ^ /terms-of-use.html redirect;
I have some foreign spam analyzer which I'm running like fastcgi server 
written in perl.
I tried to use $request_body as fastsgi_param arg, it was empty;
Wrote module which creates $post_body var in rewrite stage and with echo 
$post_body it works, but on subrequest it gives empty body (I guess 
because it not passing POST into subrequest)
maybe somebody have any ideas how to realize it other way, or may be how 
to get POST in subrequest?

Thank you any ideas.

>> because subrequest have empty request_body, that's was the reason why I'm
>> trying to pass request_body to subrequest. May be people here tried other
>> variants or have some ideas to have good quality of post analysis
>> internally?
> I don't think it's a good idea to use subrequests here just for post
> body analysis. A rewrite phase or post access phase handler seems
> rather sufficient to me.
> Passing request bodies to a subrequest is as simple as passing
> r->request_body->bufs to sr->request_body->bufs.
> Cheers,
> -agentzh

More information about the nginx mailing list