kovpack
kovpack

Reputation: 5045

Nginx + Rails 4 assets not found

I've just deployed my first Rails app to production, but encountered error: my assets for some reason are not served by nginx. Assets are compiled and exist. Names are correct, paths correct. Instead of assets nginx sends me 404 error. As a server I use Puma if that matters.

My config for that part looks like this:

  location ~* ^/assets/ {
    # Per RFC2616 - 1 year maximum expiry
    expires 1y;
    add_header Cache-Control public;

    # Some browsers still send conditional-GET requests if there's a
    # Last-Modified header or an ETag header even if they haven't
    # reached the expiry date sent in the Expires header.
    add_header Last-Modified "";
    add_header ETag "";
    break;
  }

Upvotes: 2

Views: 2332

Answers (1)

kovpack
kovpack

Reputation: 5045

I've found the source of problems. I am using Capistrano for deploy, so in my nginx config I gave wrong root path

server {
  listen 80;
  server_name mydomain.com www.mydomain.com;
  root /var/www/my_portal/current/public;

I missed current part in the root path, cause Capistrano symlinked it to current release of my app.

Upvotes: 3

Related Questions