[英]Nginx isn't serving static rails asset files
My nginx.conf file is using the recommended config from the rails guides: 我的nginx.conf文件正在使用Rails指南中推荐的配置:
server {
listen 80;
server_name mysite.org;
root /home/ec2-user/sites/mysite/production/current/public;
location ~ ^/assets/ {
expires 1y;
add_header Cache-Control public;
add_header ETag "";
break;
}
location / {
proxy_pass http://backend-mysite;
}
}
Problem is requests for css and js compiled files like this: 问题是对CSS和JS编译文件的请求如下:
http://mysite.org/assets/application-0230217054b1f5b5f386a270a526ceca.css
are returning 403 status. 正在返回403状态。
I've taken a look and I can see the asset files are there in public/assets/ 我看了一下,可以看到资产文件在public / assets /
What is wrong with my nginx configuration? 我的nginx配置有什么问题?
Figured it out. 弄清楚了。 I wasn't looking at the nginx error log before for some reason.
出于某种原因,我之前没有看过nginx错误日志。 Once I looked there I could see that those assets were getting "permission denied" error for them.
当我查看那里时,我可以看到这些资产正在为他们“拒绝权限”错误。 I tracked down this problem and had to make sure every directory from the root to the location of the asset files had:
我找到了这个问题,必须确保从根目录到资产文件位置的每个目录都具有:
chmod +x
on it. 在上面。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.