How to use $request_body?

Maxim Dounin mdounin at mdounin.ru
Mon Oct 4 21:53:57 MSD 2010


Hello!

On Mon, Oct 04, 2010 at 05:27:35PM +0200, witekfl at gazeta.pl wrote:

> On Mon, Oct 04, 2010 at 01:33:23PM +0400, Boris Dolgov wrote:
> > On Mon, Oct 4, 2010 at 12:04, witekfl Gazeta.pl <witekfl at gazeta.pl> wrote:
> > > Hi,
> > > There is in config:
> > > location / {
> > >     root blabla;
> > -     if ($request_body ~* (blabla|bebe)) {
> > +     if ($request_body ~* "(blabla|bebe)") {
> > >          return 404;
> > >     }
> > > }
> > > nginx -t says invalid condition "$request_body".
> 
> I gave wrong example. There were spaces in original config.
> Nevermind.
> 
> I'll answer myself.
> References to $request_body must follow fastcgi_pass or proxy_pass, eg.

It doesn't matter.

> location / {
>     root blabla;
>     proxy_pass http://apache;
>     if ($request_body ~* (blabla|bebe)) {
>         return 404;
>     }

$request_body won't be available during rewrite phase anyway.  
It's read only by content handlers, and this happens after 
rewrites.

Maxim Dounin



More information about the nginx-devel mailing list