首先,道歉:我知道 403 Forbidden 问题是 Rails/Nginx 安装的常见问题,但到目前为止我读过的答案都没有为我解决这个问题。
免责声明:这是我第一次在不是 Heroku 的地方部署 Rails 应用程序。请温柔一点。;)
情况:我有一个运行在 Ubuntu 12.04 服务器上的 Rails 应用程序,运行 Nginx(与Passenger 一起安装)。
我已将我的应用程序正确部署到我的服务器,但是当我尝试访问该站点时,我收到 403 Forbidden 错误。
检查我的错误日志,我看到:
2013/10/23 22:47:01 [error] 27954#0: *105 directory index of "/var/www/colepeters.com/current/public/" is forbidden, client: 50.3…server: colepeters.com, request: "GET / HTTP/1.1", host: "colepeters.com"
2013/10/23 22:47:10 [error] 27954#0: *106 directory index of "/var/www/colepeters.com/current/public/" is forbidden, client: 184…server: colepeters.com, request: "GET / HTTP/1.1", host: "colepeters.com"
2013/10/23 22:47:12 [error] 27954#0: *107 directory index of "/var/www/colepeters.com/current/public/" is forbidden, client: 151…server: colepeters.com, request: "GET / HTTP/1.1", host: "colepeters.com"
但是,在检查此目录的权限时,我看到我设置为使用 Nginx 的用户对其具有读取和执行权限。
这是我的 nginx.conf 中的相关信息:
user XXXX;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
passenger_root /home/cole/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.21;
passenger_ruby /home/cole/.rvm/wrappers/ruby-2.0.0-p247/ruby;
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name colepeters.com www.colepeters.com;
passenger_enabled on;
root /var/www/colepeters.com/current/public/;
rails_env production;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /var/www/colepeters.com/current/public;
index index.html index.htm;
# autoindex on;
}
对于解决此问题,我将不胜感激。谢谢!
更新 我已经更正了错误的passenger_ruby路径,但是403 Forbidden仍然存在,即使在重新启动Nginx之后也是如此。