fix(nginx): add SPA routing and security headers

This commit is contained in:
2026-07-27 10:21:06 +00:00
parent 4592338fdf
commit 2cf60fa522
3 changed files with 52 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
server {
listen 80;
server_name _;
root /usr/share/nginx/html;
index index.html index.htm;
# Security Headers
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "no-referrer-when-downgrade" always;
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline';" always;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
location / {
try_files $uri $uri/ /index.html;
}
# Cache static assets
location ~* \.(?:css|js|jpg|svg)$ {
expires 30d;
add_header Cache-Control "public";
}
# Cache index.html (no cache to prevent stale data)
location = /index.html {
add_header Cache-Control "no-store, no-cache, must-revalidate";
}
}