diff --git a/ci/config/nginx/default.conf b/ci/config/nginx/default.conf index 85fa35f..76828de 100644 --- a/ci/config/nginx/default.conf +++ b/ci/config/nginx/default.conf @@ -2,6 +2,9 @@ server { listen 80; server_name localhost; + root /usr/share/nginx/html; + index index.html; + # Gzip compression gzip on; gzip_vary on; @@ -18,21 +21,8 @@ server { return 302 /$locale/; } - # English locale - location /en/ { - alias /usr/share/nginx/html/en/; - index index.html; - try_files $uri $uri/ $uri.html /en/index.html; - } - - # Russian locale - location /ru/ { - alias /usr/share/nginx/html/ru/; - index index.html; - try_files $uri $uri/ $uri.html /ru/index.html; - } - - # Cache hashed static assets (JS, CSS, fonts) + # 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"; @@ -44,6 +34,16 @@ server { add_header Cache-Control "public, no-transform"; } + # 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; + } + # Error pages error_page 404 /en/index.html; }