From 90bf68c4c8e9169aecc4c8d09197174f91861a50 Mon Sep 17 00:00:00 2001 From: Vladimir Eremin Date: Mon, 16 Mar 2026 01:33:29 +0300 Subject: [PATCH] =?UTF-8?q?fix(nginx):=20add=20explicit=20root=20and=20fix?= =?UTF-8?q?=20regex=20location=20priority=20for=20sta=E2=80=A6=20(#8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …tic assets Regex locations (~* .js|css|woff2 etc) have higher priority than prefix locations (/en/, /ru/) in nginx. Without an explicit root in the server block, the caching location had no root to serve files from, causing 404s for all /en/static/... and /ru/static/... assets. - Add root /usr/share/nginx/html to server block so all locations inherit it - Remove alias from /en/ and /ru/ locations (redundant with explicit root) - Reorder: caching regex locations before locale prefix locations (documents intent) Made-with: Cursor --- ci/config/nginx/default.conf | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) 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; }