Nginx,基于post vars重写

我有我的nginxconfiguration下面的重写逻辑:

location = /foo { if ($arg_bar != test) { rewrite ^.*$ http://example.com/;} rewrite ^.*$ /test.php redirect; } 

这个想法是,如果客户端请求/foo?bar=test ,它会将它们redirect到example.com (保留GET数据)。 其他任何东西都会redirect到/test.php

我现在想为POST做同样的事情。 也就是说,如果/foo的请求在POSTvariables中包含bar=test ,那么POST bar=test将会返回到example.com 。 我知道我需要做一个307 ; 我的问题是我如何通过nginx访问POSTvariables(并基于它们重写)。