首先,道歉:我知道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,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,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; }
我非常感谢任何解决这个问题的帮助.谢谢!