2015-06-21 56 views
3

Hello My App工作正常,直到Linode在服务器上进行某种硬件更新。服务器上的所有文件仍然存在,并且所有内容都与以前一样。我联系了Linode,他们提到这可能是某处的权限问题(我找不到),他们无法提供更多帮助。Linode更新 - 403禁止使用Rails和Passenger Nginx

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/[email protected]/gems/passenger-4.0.53 

其中红宝石

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

nginx.conf具有下列设置:

http { 
    passenger_root /home/aurelplouf/.rvm/gems/[email protected]/gems/passenger-5.0.11; 
    passenger_ruby /home/aurelplouf/.rvm/gems/[email protected]/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; 
     } 
    } 
} 

UPDATE 最后我检查公用文件夹

[email protected]:~/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 
+0

在你的公共目录下运行'ls -al'。如果没有'-a'标志,则不包括该目录本身的权限。 –

+0

谢谢安德鲁,我刚刚更新了我的答案。 –

+0

你能为你的网站添加你的** nginx.conf **的'server'部分吗? – sjaime

回答

3

passenger_enabled指令只能在你的配置文件,一旦出现该文件的权限。将其保留在服务器级别并删除location /块。

而且,你可能要考虑你的server部分增加一个资产区块允许在浏览器中的静态资产缓存(只要你使用的轨道资产管道,你应该):

http { 
    passenger_root /home/aurelplouf/.rvm/gems/[email protected]/gems/passenger-5.0.11; 
    passenger_ruby /home/aurelplouf/.rvm/gems/[email protected]/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; 
    } 
    } 
} 
+0

所以我解决了这个问题,这并不是我的配置,尽管我已经考虑了您的意见。权限和Nginx配置非常好。然而,Linode进行了硬件维护,这是问题的根源,尽管重新启动并重新加载Nginx服务并没有帮助。重新安装Passenger Gem,Passenger-nginx-module后,我找到了nginx.pid。重新启动不会杀死pid,所以我只是运行'kill pid'命令,现在它可以工作。感谢您的帮助! –

+0

我用解决方案更新了答案,并会给你赏金。我找不到与我的问题有关的与计算器上的PID有关的任何信息,所以这会帮助别人在这个问题上绊倒。 **如果需要,请批准我的编辑或重新格式化** –

+0

很高兴您在最后得到它。我认为我无法批准您的修改,因为它会进入审核队列,任何具有足够信誉的SO成员都会投票批准或拒绝该投票(需要数张投票)。 – sjaime