Skip to content

Commit cd60f3f

Browse files
committed
Fix serving of assets via nginx
Changes and notes provided by Shaun Bathgate: • ^/dmp-pgd-staging/assets/(.*)$ captures everything after /assets/ into $1. • alias /usr/share/nginx/html/assets/; means Nginx maps $1 → /usr/share/nginx/html/assets/<$1>. • try_files $1 =404; ensures that if <filename> doesn’t exist, you get a 404 – and if it does exist, you get the file directly.
1 parent 37bb135 commit cd60f3f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

nginx.conf.template

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ server {
77
return 200 "healthy\n";
88
}
99

10-
location ~ ^${RAILS_RELATIVE_URL_ROOT}/assets/ {
10+
location ~ ^${RAILS_RELATIVE_URL_ROOT}/assets/(.*)$ {
1111
alias /usr/share/nginx/html/assets/;
1212
expires 1y;
1313
add_header Cache-Control "public, max-age=31536000, immutable";
1414
add_header X-Debug-Path $request_filename always;
15+
# Let Nginx check /usr/share/nginx/html/assets/<captured-path>
16+
# If missing, return 404
17+
try_files $1 =404;
1518

1619
add_header X-Frame-Options "DENY" always;
1720
add_header X-Content-Type-Options "nosniff" always;

0 commit comments

Comments
 (0)