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.
This commit is contained in:
wizardchen
2026-03-03 21:49:17 +08:00
committed by lyingbug
parent 4192cfd072
commit de6e0783b7
+3 -2
View File
@@ -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;