mercredi 18 mai 2016

Assets Directory returning 404 via SSL on unicorn nginx Ubuntu 14

This is similar question to this one, but suggested answer does not work.

I have confirmed that the assets exist, and restart nginx as well as unicorn service.

$ service nginx restart
$ service unicorn_app_name restart

This is my /etc/nginx/sites-enabled/[app_name] config.

upstream unicorn {
    server unix:/home/unicorn_user/apps/app_name/shared/sock/unicorn.unicorn_user.sock fail_timeout=0;
}

server {
 listen 80;
 server_name  staging.mydomain.org mydomain.org;

# Do not use a /tmp folder or other users can obtain certificates.
        location '/.well-known/acme-challenge' {
        default_type "text/plain";
        root        /etc/letsencrypt/webrootauth;
     }

        location / {
        rewrite ^/(.*) http://ift.tt/1TYObmi permanent;
        }
}

ssl_certificate      /etc/letsencrypt/live/http://ift.tt/1OIvvLr;
ssl_certificate_key  /etc/letsencrypt/live/http://ift.tt/1TYO8qD;

server {
    listen 443 ssl;

    server_name http://ift.tt/1OIvyXI;
    rewrite ^(.*) http://ift.tt/1TYObmi permanent;
}

server {
    listen 443 ssl;
    server_name staging.mydomain.org;
    root /home/unicorn_user/apps/app_name/current/public;

    try_files $uri/index.html $uri @unicorn;
    location @unicorn {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_redirect off;
        proxy_pass http://unicorn;
    }

    location ~ ^/(assets)/ {
        gzip_static on;
        expires max;
        add_header Cache-Control public;
        #add_header Last-Modified "";
        #add_header ETag "";
    }
    error_page 500 502 503 504 /500.html;
    client_max_body_size 4G;
    keepalive_timeout 60;
}

Seeing the 404's in the error and access logs. For example:

2016/05/18 07:46:01 [error] 2490#0: *4 open() "/home/unicorn_user/apps/app_name/current/public/assets/loading.gif" failed (2: No such file or directory), client: ip_address, server: staging.mydomain.org, request: "GET /assets/loading.gif HTTP/1.1", host: "staging.mydomain.org", referrer: "http://ift.tt/1TYOi12"

Permissions on all the assets are 644 and 755, owned by unicorn_user and in same group name.

Can anyone make another suggestion for a log or configuration to check, a service to restart? Is there an nginx config misconfiguration?

Aucun commentaire:

Enregistrer un commentaire