Hello

Igor Sysoev is at rambler-co.ru
Mon Jul 23 13:45:29 MSD 2007


On Mon, Jul 23, 2007 at 02:03:31AM -0700, Mansoor Peerbhoy wrote:

> Anyway, a quick question:
> 
> I am using NGINX as an HTTP (reverse) proxy, and I need to conditionally redirect some URLs to an external FASTCGI server. 
> I have read the HTTP rewrite module documentation at http://wiki.codemongers.com/NginxHttpRewriteModule and I see that there are ways to conditionally rewrite certain URLs.
> 
> I wonder if there is any complete set of NGINX variables ( A sort of NGINX variable reference ) that I can refer to ?
> 
> The reason I ask for such a reference is, because the conditions for a rewrite, in my case, are rather complicated.

The most of nginx variables has the same names as in Apache.

http://wiki.codemongers.com/NginxHttpCoreModule#variables

> For instance, I should like to say:
> . If URL begins with /xxxx/ AND if the HTTP method is POST, AND if there is no cookie named CCCC in the HTTP header, then redirect the url to /abc/def/ otherwise let it fall through to the default handler.

> I wonder if this is possible using the syntax described at http://wiki.codemongers.com/NginxHttpRewriteModule

The ngx_http_rewrite_module currently has many limits and drawbacks.

You may try the following:

     location /xxxx/ {
         set  $test "";

         if ($request_method = POST) {
             set $test  P;
         }

         if ($http_cookie ~* "CCCC=.+(?:;|$)" ) {
             set $test  ${test}C";
         }

         if ($test = PC) {
             fastgci_pass  ...;
         }

         # you have to set fastcgi_param at this level,
         # however, it does not mean that request goes to fastcgi

         fastcgi_param ...;
         fastcgi_param ...;
         fastcgi_param ...;

         ...
     }



-- 
Igor Sysoev
http://sysoev.ru/en/





More information about the nginx mailing list