try_files, POST, and redirecting requests to Passenger
Jason R.
lists at ruby-forum.com
Wed Jan 9 19:39:33 UTC 2013
"António P. P. Almeida" <appa at perusio.net> wrote in post #1091605:
> On 9 Jan 2013 15h22 CET, lists at ruby-forum.com wrote:
>
>>> try_files /maintenance.html @passenger;
>>> }
>>
>> I never knew about the map directive, that's quite interesting. One
>> question though, will this make sure that a POST that hits the
>> error_page 418 stays a POST when it goes through the @idempotent
>> location?
>
> Perhaps I misunderstood. The way it is configured above is such that
> the @idempotent location will only be used for GET and HEAD requests.
> All other requests are handled by the / location using the lenghty
> try_files.
>
> I thought that was your desired config.
>
>> Thanks for the info!
>
> You're welcome.
>
> --- appa
Sorry if I mispoke then, what I want is the exact opposte because POST
should never hit a cache file.
We ended up going a slightly different route in that we hack the cache
file location according to the request type (we have $cache_host because
there's some other processing we do, not relevant here):
# Set cache_path to a non-existant directory so try_files fails if we
cannot
# serve the request from the cache.
set $cache_path "no-cache";
set $cache_host $host;
if ($request_method ~* ^(GET|HEAD)$) {
set $cache_path "cache";
}
try_files
/$cache_path/$cache_host/$uri
/$cache_path/$cache_host/$uri.html
/$cache_path/$cache_host/$uri/index.html
/maintenance.html
@passenger;
This way there's no possible way a valid file is found when POST-ing.
This was the simplest solution we could come up with at this time.
Thanks for everyone's help.
Jason
--
Posted via http://www.ruby-forum.com/.
More information about the nginx
mailing list