本文介绍了403禁止在带有Nginx的Rails应用程序上使用,乘客的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,道歉:我知道403 Forbidden问题是Rails/Nginx安装的一个常见问题,但是到目前为止,我没有看到任何答案可以为我解决.

First off, apologies: I know the 403 Forbidden question is a common one for Rails/Nginx installs, but none of the answers I've read so far have solved it for me.

免责声明:这是我第一次在非Heroku的地方部署Rails应用程序.请保持温柔. ;)

Disclaimer: This is my first time deploying a Rails app somewhere that isn't Heroku. Please be gentle. ;)

情况:我有一个在Ubuntu 12.04服务器上运行的Rails应用程序,该服务器运行Nginx(已与Passenger一起安装).

Situation: I have a Rails app running on an Ubuntu 12.04 server, running Nginx (installed with Passenger).

我已经正确地将应用程序部署到服务器上,但是当我尝试访问该网站时,我收到403禁止错误.

I've deployed my app to my server correctly, but when I attempt to access the site, I receive a 403 Forbidden error.

检查我的错误日志,我看到:

Checking my error logs, I see:

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的用户具有对该目录的读取和执行权限.

However, when checking permissions on this directory, I see that the user I have setup to use Nginx had both read and execute permissions on it.

以下是我的nginx.conf中的相关信息:

Here's the relevant info from my 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;
        }

对于解决此问题的任何帮助,我将不胜感激.谢谢!

I would greatly appreciate any help on resolving this. Thanks!

更新此后,我已经纠正了错误的passenger_ruby路径,但是即使重新启动Nginx之后,"403 Forbidden"仍然存在.

UPDATEI have since corrected the erroneus passenger_ruby path, but the 403 Forbidden is persisting, even after restarting Nginx.

推荐答案

您可以使用

passenger-config --root

以及使用

which ruby

然后将其与nginx.conf中插入的内容进行比较.

then compare with the inserted in nginx.conf.

这篇关于403禁止在带有Nginx的Rails应用程序上使用,乘客的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 17:42