Rails 3.1, nginx, Passenger directory index forbidden

alexlod picture alexlod · Nov 15, 2011 · Viewed 15.2k times · Source

I'm getting the following error in nginx (with a 403) when I visit .com:

[error] 5384#0: *1 directory index of "/u/apps/<app-name>/current/public/" is forbidden

I'm on Ubuntu 10.04 and I can't for the life of me get nginx, Passenger, Rails 3.1, and Capistrano to play nicely.

I'm deploying to /u with Capistrano. Everything in /u is 755, owned by the app user.

/u/apps//current/public/ has all my assets, the favicon, and everything else you'd expect.

When I add autoindex on to nginx.conf I get a listing of the public/ directory, which leads me to believe that I don't have a permission problem.

My nginx.conf file is default expect for:

server {
    listen 80;
    server_name <app-name>.com;
    passenger_enabled on;
    root /u/apps/<app-name>/current/public/;
}

And my Capistrano deploy.rb file has nothing unusual.

Any ideas why the rails app doesn't seem to be starting?

Answer

alexlod picture alexlod · Nov 15, 2011

Alright, I answered my own question. I was missing passenger_ruby and passenger_root configurations in my nginx.conf file. Note that the passenger_ruby path needs to be the wrapper if you're using RVM.

passenger_root /usr/local/rvm/gems/ruby-1.9.2-p290/gems/passenger-3.0.9;
passenger_ruby /usr/local/rvm/wrappers/ruby-1.9.2-p290/ruby;