Skip to content

Commit 76a4fc2

Browse files
pulk17canihavesomecoffee
authored andcommitted
redirect bare /app and keep hsts on console responses
add_header in a location drops the server-level hsts header, and index.html was never revalidated after a deploy.
1 parent d07c2a2 commit 76a4fc2

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎install/nginx.conf‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,28 @@ server {
4747
# Web console: a static build served straight off disk. Everything it
4848
# talks to is under /api on this same host, so no CORS is involved.
4949
#
50+
location = /app {
51+
return 301 /app/;
52+
}
53+
5054
# The directory is named to match the URL so plain root resolution
5155
# applies. "alias" with try_files appends the whole URI to the alias
5256
# rather than the remainder, which silently breaks the SPA fallback.
5357
location ^~ /app/ {
5458
include /etc/nginx/mime.types;
5559
root NGINX_DIR/web;
5660
try_files $uri $uri/ /app/index.html;
61+
# index.html names the hashed bundles, so it must be revalidated or a
62+
# browser keeps loading the previous build after a deploy. "expires"
63+
# rather than add_header: any add_header here would stop the server
64+
# block's HSTS header being inherited.
65+
expires -1;
5766
}
5867

5968
location ^~ /app/assets/ {
6069
include /etc/nginx/mime.types;
6170
root NGINX_DIR/web;
62-
expires 30d; # hashed filenames
63-
add_header Cache-Control "public, immutable";
71+
expires max; # hashed filenames
6472
}
6573

6674
location / {

0 commit comments

Comments
 (0)