nginx + Rails 3.1 + Cloudfront资产子目录404丢失
问题描述:
我正在使用Rails 3.1资产管道,它使用自定义来源Cloudfront CDN提供服务。nginx + Rails 3.1 + Cloudfront资产子目录404丢失
这是我已经写在我的nginx.conf服务于资产gzip和缓存:
location ^~ /assets/ {
allow all;
gzip_http_version 1.0;
gzip_static on;
expires 365d;
add_header Last-Modified "";
add_header ETAg "";
add_header Cache-Control public;
}
的问题是,例如子目录/ background /在我的图片资源文件夹中,它们的项目缺少404s。
当我禁用上面的nginx位置配置问题消失。如何正确配置nginx来为子目录中的资源提供服务?
感谢
答
这为我工作:
location ~ ^/(assets)/ {
root /opt/appname/public; # or whatever the path is to your app's public folder
gzip_http_version 1.0;
gzip_static on;
access_log off;
expires 1y;
add_header Cache-Control public;
add_header Last-Modified "";
add_header ETag "";
break;
}
你有没有想出解决办法? – NudeCanalTroll 2012-04-19 03:08:18
抱歉需要一段时间才能回来。但是,我今天试了一下,效果很好!谢啦。 – davicta 2012-04-25 06:58:16