2 changed files with 57 additions and 40 deletions
@ -1,42 +1,58 @@ |
|||||
server { |
server { |
||||
listen 8080; |
listen 8080; |
||||
server_name localhost; |
server_name localhost; |
||||
|
|
||||
root /usr/share/nginx/html; |
root /usr/share/nginx/html; |
||||
index index.html index.htm; |
index index.html; |
||||
|
|
||||
location / { |
# Serve static assets directly (hashed filenames get long cache) |
||||
try_files $uri $uri/ /index.html; |
location ~* \.(?:js|mjs|css|png|jpg|jpeg|gif|ico|webp|avif|svg|ttf|otf|woff|woff2|map)$ { |
||||
} |
access_log off; |
||||
|
etag on; |
||||
error_page 500 502 503 504 /50x.html; |
|
||||
location = /50x.html { |
# If you build with hashed filenames (e.g. app.abc123.js), cache hard: |
||||
internal; |
expires 1y; |
||||
} |
add_header Cache-Control "public, immutable"; |
||||
|
try_files $uri =404; |
||||
location ~ /\.ht { |
} |
||||
deny all; |
|
||||
} |
# Never cache index.html so deploys go live immediately |
||||
|
location = /index.html { |
||||
gzip on; |
etag on; |
||||
gzip_disable "msie6"; |
add_header Cache-Control "no-cache"; |
||||
|
} |
||||
gzip_vary on; |
|
||||
gzip_proxied any; |
# SPA fallback for client-side routes |
||||
gzip_comp_level 6; |
location / { |
||||
gzip_buffers 16 8k; |
try_files $uri $uri/ /index.html; |
||||
gzip_http_version 1.1; |
} |
||||
gzip_types |
|
||||
text/plain |
# Basic error page (optional) |
||||
text/css |
error_page 500 502 503 504 /50x.html; |
||||
text/xml |
location = /50x.html { internal; } |
||||
text/javascript |
|
||||
application/javascript |
# Security hardening |
||||
application/x-javascript |
location ~ /\.ht { deny all; } |
||||
application/json |
|
||||
application/xml |
# Gzip (works fine with your asset types) |
||||
application/xml+rss |
gzip on; |
||||
font/ttf |
gzip_disable "msie6"; |
||||
font/otf |
gzip_vary on; |
||||
image/svg+xml; |
gzip_proxied any; |
||||
|
gzip_comp_level 6; |
||||
|
gzip_buffers 16 8k; |
||||
|
gzip_http_version 1.1; |
||||
|
gzip_types |
||||
|
text/plain |
||||
|
text/css |
||||
|
text/xml |
||||
|
text/javascript |
||||
|
application/javascript |
||||
|
application/x-javascript |
||||
|
application/json |
||||
|
application/xml |
||||
|
application/xml+rss |
||||
|
font/ttf |
||||
|
font/otf |
||||
|
image/svg+xml; |
||||
} |
} |
||||
|
|||||
Loading…
Reference in new issue