From 955f46c9cac3a02767b34e224fb94e4aca7a613c Mon Sep 17 00:00:00 2001 From: jze9 Date: Wed, 20 May 2026 19:42:47 +0500 Subject: [PATCH] =?UTF-8?q?feat:=20=D1=80=D0=B5=D0=B4=D0=B8=D1=80=D0=B5?= =?UTF-8?q?=D0=BA=D1=82=20=D0=BD=D0=B5=D0=B8=D0=B7=D0=B2=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D0=BC=D0=B0=D1=80=D1=88=D1=80=D1=83=D1=82?= =?UTF-8?q?=D0=BE=D0=B2=20=D0=BD=D0=B0=20=D0=BA=D0=BE=D1=80=D0=B5=D0=BD?= =?UTF-8?q?=D1=8C=20/?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit nginx: любой путь кроме /admin, /editor/, /api/ редиректит на /. Использован named location @spa чтобы избежать повторной маршрутизации при внутреннем редиректе try_files → /index.html. Co-Authored-By: Claude Sonnet 4.6 --- web-react/nginx.conf | 40 +++++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/web-react/nginx.conf b/web-react/nginx.conf index f98b1e3..4245e84 100644 --- a/web-react/nginx.conf +++ b/web-react/nginx.conf @@ -1,20 +1,41 @@ server { listen 80; - # Главное React-приложение - location / { - root /usr/share/nginx/html/app; - try_files $uri /index.html; + root /usr/share/nginx/html/app; + + # Named location — отдаёт React SPA без повторной маршрутизации + location @spa { + try_files /index.html =404; + } + + # Корневая страница + location = / { + try_files /index.html =404; + } + + # Статические ассеты приложения (JS, CSS, шрифты, картинки) + location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot|json|map)$ { + try_files $uri =404; + } + + # Админ-панель — React SPA, все вложенные пути разрешены + location ^~ /admin { + try_files $uri @spa; } # Редактор статей (отдельный React-билд) - location /editor/ { + location ^~ /editor/ { root /usr/share/nginx/html; - try_files $uri /editor/index.html; + try_files $uri @editor_spa; + } + + location @editor_spa { + root /usr/share/nginx/html; + try_files /editor/index.html =404; } # Статические ассеты редактора (Vite base: '/editor-assets/') - location /editor-assets/ { + location ^~ /editor-assets/ { alias /usr/share/nginx/html/editor/; } @@ -26,6 +47,11 @@ server { proxy_buffering off; } + # Всё остальное — редирект на корень + location / { + return 302 /; + } + gzip on; gzip_types text/plain text/css application/json application/javascript text/xml application/xml; }