Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a Rails app that is caching pages in multiple custom directories. Everything works fine other than non GET requests, which are delivering 405 errors in Nginx because my configuration is not routing them to passenger. My question is what is the most efficient way to forward non GET request directly to passenger?

My nginx.conf currently looks like this:

server {
       server_name railsapp.local;
       root /Users/i0n/Sites/railsapp/public;
       location / {
               try_files $uri /$host/$uri/index.html /$host/$uri.html /$host/$uri @passenger;
       location @passenger {
               passenger_enabled on;
share|improve this question
if ($request_method != 'GET') {
    passenger_enabled on;    
share|improve this answer
I'm not sure that this will work. I think I tried this and hit problems. I solved the problem in a slightly different way, see below. – i0n Feb 18 '12 at 17:40
up vote 0 down vote accepted

So I couldn't find an efficient error free way of achieving this. The problem was that if a folder was created in the Rails cache, then a route matching this folders name would resolve to the folder statically before checking the Rails route (breaking update create and destroy actions). I resolved this by creating custom route names for the paths that conflicted with the cached folders. Now everything works fine.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.