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;
       }
}
link|improve this question

50% accept rate
feedback

2 Answers

if ($request_method != 'GET') {
    passenger_enabled on;    
}
link|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 at 17:40
feedback
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.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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