try_files, POST, and redirecting requests to Passenger
Jason R.
lists at ruby-forum.com
Tue Jan 8 23:13:17 UTC 2013
The application I'm working on (CMS) has a few interesting requirements:
* Custom user domains
* Very heavily page cached.
* Any page can be POSTed to (page has a form on it)
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;
}
I initially had the idea that try_files was more of a switch-statement,
and tried to do something like:
try_files @cache maintenance.html @passenger;
then in @cache simply break if the request is not a GET, but that
obviously only ever went to @passenger, because @cache wasn't a real
file on the system.
I've tried the error_page 405 = @passenger route, but that has a very
severe problem in that it turns my POST request into a GET, and I was
unable to find out how to stop that. Is there a way?
I've also tried doing an internal redirect to a different location
block, something like:
location /post {
internal;
passenger_enabled on;
}
but then I end up with $uris that have /post/(uri i want) and don't know
how to tell nginx to ignore /post when sending down to passenger. Would
also appreciate ideas here if there are any.
Any other suggestions? I'm almost to resorting to a number of if
statements and really don't want to end up there.
I am using nginx release: 1.2.6 on ubuntu 12.04 and Passenger
Enterprise.
Thanks
Jason
--
Posted via http://www.ruby-forum.com/.
More information about the nginx
mailing list