From de6e0783b7a2a2c6d4dc1dff10062249aa65faa9 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Tue, 3 Mar 2026 21:49:17 +0800 Subject: [PATCH] refactor: improve Nginx configuration for file handling - Changed the location directive for `/files` to an exact match to prevent Nginx from appending a trailing slash, which could trigger a 301 redirect. - Updated the proxy_pass directive to ensure proper handling of file requests, enhancing the efficiency of the backend service integration. These changes streamline the Nginx configuration for file handling, improving request management. --- frontend/nginx.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/nginx.conf b/frontend/nginx.conf index 1349d0d8..ad114732 100644 --- a/frontend/nginx.conf +++ b/frontend/nginx.conf @@ -22,8 +22,9 @@ server { } # 本地存储文件代理到后端服务(用于渲染 markdown 中的图片) - location /files/ { - proxy_pass ${APP_SCHEME}://${APP_HOST}:${APP_PORT}/files/; + # 精确匹配 /files,避免 Nginx 自动补 / 触发 301 + location = /files { + proxy_pass ${APP_SCHEME}://${APP_HOST}:${APP_PORT}/files; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;