Rails 3.1、nginx、禁止乘客目录索引 [英] Rails 3.1, nginx, Passenger directory index forbidden

查看:29
本文介绍了Rails 3.1、nginx、禁止乘客目录索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我访问 .com 时,我在 nginx 中收到以下错误(带有 403):

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

我使用的是 Ubuntu 10.04,但我终生无法让 nginx、Passenger、Rails 3.1 和 Capistrano 正常运行.

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.

我正在使用 Capistrano 部署到/u./u 中的所有内容都是 755,归应用用户所有.

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

/u/apps//current/public/包含我的所有资产、网站图标以及您期望的所有其他内容.

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

当我将 autoindex on 添加到 nginx.conf 时,我得到了 public/目录的列表,这让我相信我没有权限问题.

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.

我的 nginx.conf 文件默认为:

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/;
}

我的 Capistrano deploy.rb 文件没有任何异常.

And my Capistrano deploy.rb file has nothing unusual.

有什么想法为什么 Rails 应用程序似乎没有启动?

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

推荐答案

好的,我已经回答了我自己的问题.我的 nginx.conf 文件中缺少passenger_ruby 和passenger_root 配置.请注意,如果您使用的是 RVM,则passenger_ruby 路径需要是包装器.

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;

这篇关于Rails 3.1、nginx、禁止乘客目录索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆