Files
ToBePlayed-Frontend/nginx.conf
T
lobo 6edb53162e
Build, Test & Push Frontend / quality-check (push) Successful in 14s
Build, Test & Push Frontend / docker (push) Successful in 23s
feat(security): add a report-only CSP and security headers
nginx.conf is now an nginx template, so connect-src takes
AUTH_HOST and API_HOST from the container env. The image
sets both to empty by default, so nginx still starts
without them. Report-only until production shows no
violation. Also nosniff, Referrer-Policy and
Permissions-Policy.
2026-09-25 15:47:23 +02:00

35 lines
1.8 KiB
Nginx Configuration File

server {
listen 80;
root /usr/share/nginx/html;
# An nginx template: AUTH_HOST and API_HOST come from the container env at start (see Dockerfile).
# Report-Only until production shows no violation in the browser console; then rename the header.
add_header Content-Security-Policy-Report-Only "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://*.steamstatic.com https://steamcdn-a.akamaihd.net https://media.steampowered.com https://images.igdb.com; font-src 'self' data:; connect-src 'self' https://${AUTH_HOST} https://${API_HOST}; manifest-src 'self'; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "camera=(), microphone=(), geolocation=()" always;
# Keeps the headers above in the locations that add their own Cache-Control (nginx 1.29.3 and later).
add_header_inherit merge;
# Vite puts a content hash in these file names, so they never change.
location /assets/ {
add_header Cache-Control "public, max-age=31536000, immutable";
}
# Not in every nginx mime.types; browsers expect this type for the PWA manifest.
location = /manifest.webmanifest {
types { application/manifest+json webmanifest; }
add_header Cache-Control "no-cache";
}
# index.html and /i18n/*.json keep their names across deploys. Without
# no-cache the browser shows old translation keys or loads an old bundle.
location / {
index index.html index.htm;
add_header Cache-Control "no-cache";
# Handle React Router navigation
try_files $uri $uri/ /index.html;
}
}