|
|
@ -5,36 +5,29 @@ server { |
|
|
root /usr/share/nginx/html; |
|
|
root /usr/share/nginx/html; |
|
|
index index.html; |
|
|
index index.html; |
|
|
|
|
|
|
|
|
# Serve static assets directly (hashed filenames get long cache) |
|
|
|
|
|
location ~* \.(?:js|mjs|css|png|jpg|jpeg|gif|ico|webp|avif|svg|ttf|otf|woff|woff2|map)$ { |
|
|
location ~* \.(?:js|mjs|css|png|jpg|jpeg|gif|ico|webp|avif|svg|ttf|otf|woff|woff2|map)$ { |
|
|
access_log off; |
|
|
access_log off; |
|
|
etag on; |
|
|
etag on; |
|
|
|
|
|
|
|
|
# If you build with hashed filenames (e.g. app.abc123.js), cache hard: |
|
|
|
|
|
expires 1y; |
|
|
expires 1y; |
|
|
add_header Cache-Control "public, immutable"; |
|
|
add_header Cache-Control "public, immutable"; |
|
|
try_files $uri =404; |
|
|
try_files $uri =404; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# Never cache index.html so deploys go live immediately |
|
|
|
|
|
location = /index.html { |
|
|
location = /index.html { |
|
|
etag on; |
|
|
etag on; |
|
|
add_header Cache-Control "no-cache"; |
|
|
add_header Cache-Control "no-cache"; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# SPA fallback for client-side routes |
|
|
|
|
|
location / { |
|
|
location / { |
|
|
try_files $uri $uri/ /index.html; |
|
|
try_files $uri $uri/ /index.html; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
# Basic error page (optional) |
|
|
|
|
|
error_page 500 502 503 504 /50x.html; |
|
|
error_page 500 502 503 504 /50x.html; |
|
|
location = /50x.html { internal; } |
|
|
location = /50x.html { internal; } |
|
|
|
|
|
|
|
|
# Security hardening |
|
|
|
|
|
location ~ /\.ht { deny all; } |
|
|
location ~ /\.ht { deny all; } |
|
|
|
|
|
|
|
|
# Gzip (works fine with your asset types) |
|
|
|
|
|
gzip on; |
|
|
gzip on; |
|
|
gzip_disable "msie6"; |
|
|
gzip_disable "msie6"; |
|
|
gzip_vary on; |
|
|
gzip_vary on; |
|
|
|