From 0c3e57f5b5ba891ac6c619d3b04b2edd4a9283ae Mon Sep 17 00:00:00 2001 From: yueli Date: Fri, 28 Aug 2026 16:46:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(nginx):=20=E7=94=9F=E4=BA=A7=20nginx=20?= =?UTF-8?q?=E4=BB=A3=E7=90=86=E6=8C=87=E5=90=91=E5=AE=B9=E5=99=A8=E5=90=8D?= =?UTF-8?q?=20inventory=5Fapi=5Fprod=20=E9=81=BF=E5=85=8D=20DNS=20?= =?UTF-8?q?=E5=86=B2=E7=AA=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 服务器上有多个 compose 项目(inventory-app / Track)都使用 backend 服务名 - nginx 中 proxy_pass http://backend:8000 会随机解析到 track_backend_prod 导致 /api/ 请求 404 - 改为使用固定容器名 inventory_api_prod:8000 --- inventory-web/nginx.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/inventory-web/nginx.conf b/inventory-web/nginx.conf index 5ad5c7c..f5eb62c 100644 --- a/inventory-web/nginx.conf +++ b/inventory-web/nginx.conf @@ -37,8 +37,10 @@ server { } # 3. 后端 API 接口代理 + # ★ 使用容器名 inventory_api_prod 而非服务名 backend, + # 避免与其他 compose 项目的 backend 服务 DNS 冲突(track_backend_prod) location /api/ { - proxy_pass http://backend:8000; + proxy_pass http://inventory_api_prod:8000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr;