proxy_pass fails after calling $r->has_request_body()

Ben Grimm lists at
Thu Dec 20 15:24:50 MSK 2007

Igor Sysoev wrote:
> 2) in 0.6.21+ you may use a variable in proxy_pass:
>    location ^~ /@map/  {
>       proxy_pass   http://$backend;
>    }

Sorry, after paring my example down it looks really contrived.  The 
$backend variable on the perl side is actually set by calling another 
sub which does regex matches on $r->uri, $r->args, and finally 
$r->request_body to find a value.  It takes the first instance it finds 
and uses it as an index to a CDB_File database.  The value from the CDB 
is used to select the proxy.

> and set the variable using perl_set.

That would work except that I can't see how to use the perl_set 
construct to read the request body (that was my first approach).  When 
the handler returns after calling has_request_body(), the value if the 
perl_set variable is undefined and nginx wants the callback to return an 
http response -- not a value to stuff into a variable.

Having request_body only accessible after a callback has become a thorn 
in my side ;-) It would certainly be easier if I could direct nginx to 
just read the request body _before_ it calls my code.

Posted via

More information about the nginx mailing list