Linode更新-禁止使用Rails和Passenger Nginx 403

前端之家收集整理的这篇文章主要介绍了Linode更新-禁止使用Rails和Passenger Nginx 403 前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

Hello My App运行良好,直到Linode在服务器上进行了某种硬件更新.服务器上的所有文件都仍然存在,并且一切似乎都与以前相同.我联系了Linode,他们提到这可能是某个地方的权限问题(我找不到),他们无法提供更多帮助.

Nginx错误日志显示以下内容

2015/06/21 18:07:23 [error] 2870#0: *19684 directory index of
"/home/aurelplouf/apps/myapp/current/public/" is forbidden,client: XXX.XXX.XXX.XXX,server: XXX.XXX.XX.XX,request: "GET / HTTP/1.1",host: "myapp.com"

我有点茫然,因为我的部分没有任何变化.

我检查了passenger-config –root

/home/aurelplouf/.rvm/gems/ruby-2.1.2@rails3.2/gems/passenger-4.0.53

哪个ruby

/home/aurelplouf/.rvm/rubies/ruby-2.1.2/bin/ruby

Nginx.conf具有以下设置:

http {
    passenger_root /home/aurelplouf/.rvm/gems/ruby-2.1.2@rails3.2/gems/passenger-5.0.11;
    passenger_ruby /home/aurelplouf/.rvm/gems/ruby-2.1.2@rails3.2/wrappers/ruby;

    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  xxx.xxx.xx.xx myapp.com www.myapp.com *.myapp.com
        root /home/aurelplouf/apps/myapp/current/public;
        passenger_enabled on;

        location / {
            #root   html;
            # root /home/aurelplouf/apps/myapp/current/public;
            # index  index.html index.htm;
            passenger_enabled on;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

更新
最后,我检查了公用文件夹中的文件权限

aurelplouf@ruby:~/apps/myapp/current$ls -al public
total 32
drwxrwxr-x  2 aurelplouf aurelplouf 4096 Jun 21 17:15 .
drwxrwxr-x 15 aurelplouf aurelplouf 4096 Jun 21 17:15 ..
-rw-rw-r--  1 aurelplouf aurelplouf  728 Feb 15  2014 404.html
-rw-rw-r--  1 aurelplouf aurelplouf  711 Feb 15  2014 422.html
-rw-rw-r--  1 aurelplouf aurelplouf  643 Feb 15  2014 500.html
lrwxrwxrwx  1 aurelplouf aurelplouf   51 Jun 21 17:13 assets -> /home/aurelplouf/apps/myapp/shared/assets
-rw-rw-r--  1 aurelplouf aurelplouf 1150 Feb 15  2014 favicon.ico
-rw-rw-r--  1 aurelplouf aurelplouf  431 Oct 21  2014 robots.txt
-rw-rw-r--  1 aurelplouf aurelplouf  340 Oct 21  2014 sitemap.xml.gz
lrwxrwxrwx  1 aurelplouf aurelplouf   51 Jun 21 17:15 system -> /home/aurelplouf/apps/myapp/shared/system
lrwxrwxrwx  1 aurelplouf aurelplouf   52 Jun 21 17:15 uploads -> /home/aurelplouf/apps/myapp/shared/uploads
最佳答案
passenger_enabled伪指令只能在您的配置文件中出现一次.将其保留在服务器级别,然后删除您的位置/街区.

另外,您可能要考虑在服务器部分中添加资产块,以允许在浏览器中进行静态资产缓存(只要您正在使用Rails资产管道,就应该这样做):

http {
  passenger_root /home/aurelplouf/.rvm/gems/ruby-2.1.2@rails3.2/gems/passenger-5.0.11;
  passenger_ruby /home/aurelplouf/.rvm/gems/ruby-2.1.2@rails3.2/wrappers/ruby;

  include       mime.types;
  default_type  application/octet-stream;
  sendfile        on;
  keepalive_timeout  65;

  server {
    listen       80;
    server_name  xxx.xxx.xx.xx myapp.com www.myapp.com *.myapp.com;
    root /home/aurelplouf/apps/myapp/current/public;
    passenger_enabled on;

    location ~ ^/(assets)/  {
            root /home/aurelplouf/apps/myapp/current/public;
            gzip_static on;
            expires max;
            add_header Cache-Control public;
            gzip_vary on;
            etag off;
    }


    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }
  }
}
原文链接:https://www.f2er.com/nginx/532279.html

猜你在找的Nginx相关文章