Nginx + Rails 4 assets not found

空扰寡人 提交于 2019-12-24 03:56:05

问题


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

回答1:


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.



来源:https://stackoverflow.com/questions/25340862/nginx-rails-4-assets-not-found

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!