Tenho quase certeza de que descobri. Basicamente, eu precisava mover o caminho da raiz para o local dos ativos e, em seguida, adicionar um retorno extra se os recursos fossem encontrados.
upstream unicorn {
server unix:/tmp/unicorn.main.sock fail_timeout=0;
server unix:/tmp/unicorn.main_staging.sock fail_timeout=0;
}
server {
listen 80;
server_name mysite.com;
### REMOVED root /var/www/sites/main/current/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 https://unicorn;
}
location ~ ^/assets/ {
root /var/www/sites/main/current/public; ## ADDED ##
try_files $uri @altassets; ## ADDED ##
expires 1y;
add_header Cache-Control public;
add_header ETag "";
break;
}
location @altass {
root /var/www/sites/main_staging/current/public;
try_files $uri $uri/;
}
error_page 500 502 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}