From a4252e05abddc064013e6c80b75bce60586a1c3f Mon Sep 17 00:00:00 2001 From: Peanut Date: Wed, 18 Mar 2026 20:06:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E9=9D=99=E6=80=81?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E8=AE=BF=E9=97=AE=E9=97=AE=E9=A2=98=E5=B9=B6?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=20life-script=20=E5=89=8D=E7=AB=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 为 /emotion-museum/assets/ 添加静态资源专用 location 处理 - 添加 /life-script/ 前端应用的 nginx 配置 - 支持 React SPA 路由和静态资源缓存策略 --- conf/nginx-emotion-museum-ssl.conf | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/conf/nginx-emotion-museum-ssl.conf b/conf/nginx-emotion-museum-ssl.conf index 008f1fb..4798464 100644 --- a/conf/nginx-emotion-museum-ssl.conf +++ b/conf/nginx-emotion-museum-ssl.conf @@ -27,6 +27,13 @@ server { location /emotion-museum/ { alias /data/www/emotion-museum/; autoindex off; + # 静态资源直接返回文件,不经过 try_files + location ~* ^/emotion-museum/(assets|static)/ { + add_header Cache-Control "public, max-age=31536000, immutable"; + expires 1y; + try_files $uri =404; + } + # SPA 路由兜底 try_files $uri $uri/ /emotion-museum/index.html; } @@ -54,6 +61,24 @@ server { rewrite ^ /course-of-life/ last; } + # life-script React 应用 + location /life-script/ { + alias /data/www/life-script/; + autoindex off; + # 静态资源直接返回文件 + location ~* ^/life-script/(assets|static)/ { + add_header Cache-Control "public, max-age=31536000, immutable"; + expires 1y; + try_files $uri =404; + } + # SPA 路由兜底 + try_files $uri $uri/ /life-script/index.html; + } + + location = /life-script { + rewrite ^ /life-script/ last; + } + location /api { proxy_pass http://127.0.0.1:19089; proxy_set_header Host $host;