我最近将我们的应用程序从3更新到4.2.7,现在我们在生产环境方面遇到了问题:
/cssfile.css
已成功加载,而/subdir/cssfile.css
则未加载。{/ li>
醇>
升级期间nginx配置文件没有变化。 config / environment / production.rb中的更改如下:
+ config.eager_load = true
- config.serve_static_assets = false
+ config.serve_static_files = false
- config.assets.compress = true
+ config.assets.js_compressor = :uglifier
+ config.assets.css_compressor = :sass
在部署时,config.assets.css_compressor = :sass
导致了问题,因此我将其删除并且预编译成功完成,不知道为什么会发生这种情况,因为我已经在Rails 4中读取了默认的css_compressor:sass。
这是网站上使用的nginx配置:
upstream SITENAME {
server unix:/home/deploy/SITENAME/shared/pids/unicorn.sock;
}
server {
listen 80;
server_name production.SITENAMEart.com;
root /home/deploy/SITENAME/current/public;
access_log /var/log/nginx/SITENAME.access.log main;
client_max_body_size 64M;
location ~ ^/assets/ {
expires max;
add_header Cache-Control public;
add_header ETag "";
break;
}
location ~ ^/(assets)/ {
root /home/deploy/SITENAME/current/public;
gzip_static on;
expires max;
add_header Cache-Control public;
}
location / {
try_files $uri @SITENAME;
}
location @SITENAME {
include proxy.conf;
proxy_pass http://SITENAME;
}
# stats url
location /nginx_stats {
stub_status on;
access_log off;
#allow SOME.IP.ADD.RESS;
#deny all;
}
}
server {
listen 443;
server_name production.SITENAMEart.com;
root /home/deploy/SITENAME/current/public;
access_log /var/log/nginx/SITENAME.access.log main;
ssl on;
ssl_certificate /usr/local/nginx/conf/ssl/wildcard.SITENAMEart.com.crt;
ssl_certificate_key /usr/local/nginx/conf/ssl/wildcard.SITENAMEart.com.key.unsecure;
ssl_client_certificate /usr/local/nginx/conf/ssl/geotrust.crt;
location ~ ^/assets/ {
expires max;
add_header Cache-Control public;
add_header ETag "";
break;
}
location / {
try_files $uri @SITENAME;
proxy_set_header X-Forwarded-Proto https;
}
location @SITENAME {
include proxy.conf;
proxy_pass http://SITENAME;
proxy_set_header X-Forwarded-Proto https;
}
# stats url
location /nginx_stats {
stub_status on;
access_log off;
}
}
最让我感到惊讶的是,在部署到生产之前,该版本已经在升级版上进行了全面测试,并且它具有nginx配置 - 没有出现任何问题。
答案 0 :(得分:0)
问题已经解决。它与我从Capistrano v2移植的自定义符号链接脚本有关,该脚本在生成资源后删除了public / assets目录的内容。
我还没有找到为什么这不是我们的登台服务器上的问题。