Linode Update - 403 Forbidden with Rails and Passenger Nginx

Hi my application is working fine until Linode did some hardware update on the server. All files on the server still exist and everything seems to be the same as before. I contacted Linode and they mentioned that it might be a permission issue somewhere (which I can't find) and they couldn't be more helpful.

The Nginx error log shows the following:

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"

      

I'm a little confused because nothing has changed on my part.

I checked passenger-config --root

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

      

which is ruby

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

      

and nginx.conf with the following configuration:

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;
        }
    }
}

      

UPDATE Finally I checked the file permissions on the shared folder

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

      

+3


source to share


1 answer


The directive passenger_enabled

can only appear once in your config file. Store it at the server level and delete the block location /

.

Also, you may need to add an assets block to the section server

to enable static caching of resources in the browser ( as long as you are using the rails resource pipeline ), which you should):



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;
    }
  }
}

      

+3


source







All Articles