我通过 Capistrano 将 Rails 3.2.8 应用程序部署到我的 Linode 服务器,并启用了资产管道。
它正在运行 nginx + unicorn。
当我访问我的应用程序时,最小化的 JS 和 CSS 没有被提供,尽管资产存在于<RAILS_DIR>/public/assets
.
$ tree assets
assets
|-- application-66e477d6fd8cf088e8be44affeead089.css
|-- application-66e477d6fd8cf088e8be44affeead089.css.gz
|-- application-7d3ead38a0b5e276a97d48e52044ac31.js
|-- application-7d3ead38a0b5e276a97d48e52044ac31.js.gz
在我的应用程序中,我可以看到没有找到那些确切的文件:
这是我的 nginx 配置:
server {
listen 80 default deferred;
server_name me.example.com;
root /home/kennym/apps/app/current/public;
location ^~ /assets/ {
add_header Last-Modified "";
add_header ETag "";
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
你能猜出出了什么问题吗?
location ^~ /assets/
应该location ~ ^/assets/
.
前者是与/资产/不匹配,后者是匹配以 /assets/ 开头的模式
更新您的 nginx 配置以使缓存和预压缩文件服务再次正常工作。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)