@@ -17,16 +17,46 @@ location @production {
1717 proxy_pass https://studio-content.storage.googleapis.com;
1818}
1919
20+ location @hotfixes_storage {
21+ include /etc/nginx/includes/content/_proxy.conf;
22+ include /etc/nginx/includes/content/_cache.conf;
23+
24+ # this is the magic that allows us to intercept errors and try the next location
25+ proxy_intercept_errors on;
26+ recursive_error_pages on;
27+ error_page 404 = @production_storage;
28+
29+ proxy_pass https://develop-studio-content.storage.googleapis.com;
30+ }
31+
32+ location @production_storage {
33+ include /etc/nginx/includes/content/_proxy.conf;
34+ include /etc/nginx/includes/content/_cache.conf;
35+
36+ proxy_pass https://studio-content.storage.googleapis.com;
37+ }
38+
2039location @nowhere {
2140 return 404;
2241}
2342
43+ # Note on try_files
44+ # -----------------
45+ # try_files will only use one named route, and it uses the last one. Although, we can't just pass
46+ # one named route, because it fails.
47+
48+ location ^~ /content/storage/ {
49+ # ensure that the /content/ prefix is stripped from the request
50+ rewrite ^/content/(.*)$ /$1 break;
51+
52+ # check staging bucket first, then fall back to production
53+ try_files @nowhere @hotfixes_storage;
54+ }
55+
2456location /content/ {
2557 # ensure that the /content/ prefix is stripped from the request
2658 rewrite ^/content/(.*)$ /$1 break;
2759
2860 # check the emulator bucket first, then cloud development bucket, then fall back to production
29- # try_files will only use one named route, and it uses the last one. Although, we can just
30- # pass one named route, because it fails.
3161 try_files @nowhere @hotfixes;
3262}
0 commit comments