POST, memcached, 405, and gateway timeouts

nginx at thomer.com nginx at thomer.com
Sat Jun 21 00:29:57 MSD 2008


Hi Igor,


Thanks for the reply.

You suggest I split the foo and bar case, but my example was bad.
Trying to "simplify" the example was a bad idea.  What I'm actually
doing is (still simplified...):

   location ~ "foo" {
     error_page 404 = /;
     error_page 405 =200 /;
   
     set $memcached_key "default";
     if ($request_uri ~ "bar(regexp1)baz(regexp2)") {
       set $memcached_key "$1:$2";
     }
     memcached_pass ...;
   }
   
   location / {
     proxy_pass ...;
   }

My understanding is that I cannot use (...) in regular expressions in
the 'location' directive.  That's the reason why the if () is inside of
the location ~ "foo" part; I'm trying to 'extract' a part of the URL.
I couldn't think of a better way to refactor the configuration.

But all that doesn't explain the problem I'm seeing (i.e., POST requests
end up causing a Gateway Error 405).  I'll send a debug file on Monday,
as you requested.

Many thanks so far.

Thomer


> On Thu, Jun 19, 2008 at 04:48:09PM -0400, nginx at thomer.com wrote:
> 
> > I have the following situation:
> > 
> >   location ~ "foo" {
> >     error_page 404 = /;
> >     error_page 405 =200 /;
> >   
> >     set $memcached_key "default";
> >     if ($request_uri ~ "bar") {
> >       set $memcached_key "non-default";
> >     }
> >     memcached_pass ...;
> >   }
> >   
> >   location / {
> >     proxy_pass ...;
> >   }
> > 
> > The "error_page 405 =200 /;" is there to make sure that POST requests
> > fall through to the "location /" block (since nginx returns 405s on
> > a POST when trying to serve cached content).
> > 
> > The problem is that this setup causes gateway timeouts.  I verified that
> > the backend is up, though: if I comment out the first location block,
> > everything works fine.  In other words, the backend is up.
> > 
> > Essentially, I'm trying to serve cached content for GET request and fall
> > back to the backend for POST requests.
> 
> Could you create debug log ?
> 
> BTW, it better to split "foo" and "bar":
> 
>    location ~ "bar" {
>        error_page 404 = /;
>        error_page 405 =200 /;
> 
>        set $memcached_key "non-default";
>        memcached_pass ...;
>    }
> 
>    location ~ "foo" {
>        error_page 404 = /;
>        error_page 405 =200 /;
>    
>        set $memcached_key "default";
>        memcached_pass ...;
>    }
> 
> 
> -- 
> Igor Sysoev
> http://sysoev.ru/en/
> 
> 





More information about the nginx mailing list