server { listen 80; server_name localhost; root /usr/share/nginx/html; index index.html; # Prevent HTTP protocol downgrade behind reverse proxy on redirects absolute_redirect off; # Security Headers (Defense in depth) add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "DENY" always; add_header Referrer-Policy "strict-origin-when-cross-origin" always; add_header Cross-Origin-Opener-Policy "same-origin" always; add_header Strict-Transport-Security "max-age=63072000; includeSubDomains; preload" always; # Gzip compression gzip on; gzip_vary on; gzip_proxied any; gzip_comp_level 6; gzip_types text/plain text/css text/xml application/json application/javascript application/rss+xml application/atom+xml image/svg+xml; # Root redirect: detect browser language, fallback to /en/ location = / { set $locale "en"; if ($http_accept_language ~* "(^|,\s*)ru") { set $locale "ru"; } return 302 /$locale/; } # Cache hashed static assets (JS, CSS, fonts) — matched before locale prefix blocks # root is inherited from server block, so /en/static/js/file.js resolves correctly location ~* \.(js|css|woff|woff2|ttf|eot)$ { expires 1y; add_header Cache-Control "public, immutable" always; add_header Access-Control-Allow-Origin "*" always; } # Cache images location ~* \.(png|jpg|jpeg|gif|ico|svg)$ { expires 1y; add_header Cache-Control "public, no-transform" always; add_header Access-Control-Allow-Origin "*" always; } # English locale — SPA fallback for non-asset routes location /en/ { try_files $uri $uri/ $uri.html /en/index.html; } # Russian locale — SPA fallback for non-asset routes location /ru/ { try_files $uri $uri/ $uri.html /ru/index.html; } # Version probe for release rollout verification location = /version.json { add_header Cache-Control "no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0" always; add_header Content-Type "application/json" always; add_header Access-Control-Allow-Origin "*" always; try_files /version.json =404; } # Error pages error_page 404 /en/index.html; }