问题
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