try_files, POST, and redirecting requests to Passenger

Jonathan Matthews contact at jpluscplusm.com
Wed Jan 9 01:31:49 UTC 2013


On 8 January 2013 23:13, Jason R. <lists at ruby-forum.com> wrote:
> In Apache, this was easily handled. If GET, then look in the cache, then
> fall to Passenger. Otherwise, just go straight to Passenger.
>
> I have been unable to get nginx working for my needs and am wondering if
> anyone else has any insight into how to solve this problem.
>
> Basically what I want is the following (but can't because try_files
> can't be in an if):
>
>   location / {
>     if ($request_method ~* ^(GET|HEAD)$) {
>       try_files /cache/$domain/$uri
>                    /cache/$domain/$uri.html
>                    /cache/$domain/$uri/index.html
>                    /maintenance.html
>                   @passenger;
>       break;
>     }
>
>     try_files /maintenance.html @passenger;
>   }
>
>   location @passenger {
>     passenger_enabled on;
>   }

Does try_files accept a variable generated from a map based on the
$request_method variable, perhaps?

That's the way I usually avoid ifs.

Jonathan
-- 
Jonathan Matthews // Oxford, London, UK
http://www.jpluscplusm.com/contact.html



More information about the nginx mailing list