From 01ae82b1f82a4b0dee369ac1f383d6b6e8df0bea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E5=AE=B6=E8=AE=AD?= Date: Tue, 20 Oct 2026 16:18:07 +0800 Subject: [PATCH] =?UTF-8?q?feat(nginx):=20todo.jiaxun.site=20=E4=B8=93?= =?UTF-8?q?=E5=B1=9E=20server=20=E5=9D=97=EF=BC=8C=E6=A0=B9=E8=B7=AF?= =?UTF-8?q?=E5=BE=84=E7=9B=B4=E8=BE=BE=E5=85=AC=E5=BC=80=E5=BE=85=E5=8A=9E?= =?UTF-8?q?=E7=9C=8B=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 按 Host 区分:todo.jiaxun.site 根路径内部重写到 todo-public.html - 该域名下 SPA 兜底也指向看板页(无 freedom 路由需求) - /api 反代规则与主站一致(backend:8800 去 /api 前缀) - 前提:VPS openresty 反代需传 Host 头(proxy_set_header Host $host) --- nginx.conf | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/nginx.conf b/nginx.conf index 89da39f..870d686 100644 --- a/nginx.conf +++ b/nginx.conf @@ -5,6 +5,58 @@ # 后端接口无 /api 前缀,因此需要去掉前缀再转发。 # 后端容器服务名:backend,端口:8800(见 docker-compose.yml) # ============================================================= + +# ------------------------------------------------------------- +# todo.jiaxun.site:公开待办看板专用域名 +# 根路径直接出看板页;SPA 兜底也指向看板页(该域名下无 freedom 路由) +# 前提:上游(VPS openresty)反代时需传 Host 头(proxy_set_header Host $host) +# ------------------------------------------------------------- +server { + listen 80; + server_name todo.jiaxun.site; + + root /usr/share/nginx/html; + index todo-public.html; + + client_max_body_size 20m; + + # /api/xxx -> backend:8800/xxx(与主站一致,去掉 /api 前缀) + location /api/ { + proxy_pass http://backend:8800/; + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + proxy_set_header Authorization $http_authorization; + proxy_connect_timeout 10s; + proxy_read_timeout 60s; + } + + # 根路径:内部重写到看板页,地址栏保持域名根路径 + location = / { + try_files /todo-public.html =404; + } + + # 其余路径:真实文件优先,兜底到看板页 + location / { + try_files $uri $uri/ /todo-public.html; + } + + # 静态资源缓存 + location ~* \.(js|css|png|jpg|jpeg|gif|svg|ico|woff2?|ttf|eot)$ { + expires 7d; + add_header Cache-Control "public, max-age=604800"; + try_files $uri =404; + } + + error_page 500 502 503 504 /50x.html; + location = /50x.html { + root /usr/share/nginx/html; + } +} + +# ---------------- 主站(IP:8880 及其他域名直达) ---------------- server { listen 80; server_name _;