From 22c1085c4bd5a979cd7ba4fdb7cbc1efd717009d Mon Sep 17 00:00:00 2001 From: xiaoxia Date: Fri, 3 Jul 2026 13:34:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B0=B8=E4=B9=85=E4=BF=AE=E5=A4=8D=20n?= =?UTF-8?q?ginx=20proxy=5Fpass=20=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - staging nginx.conf: 使用静态 proxy_pass 替代变量型(避免 URI 丢失) - staging 指向容器名 xiaoxia-api-staging(避免 DNS 别名冲突) - 添加 proxy_read_timeout/proxy_send_timeout 300s(与 production 对齐) - web.Dockerfile: 支持 ARG NGINX_CONF 参数化(与 web-artifact.Dockerfile 一致) - production nginx-production.conf 已确认无需修改 --- infra/docker/nginx.conf | 11 +++++++---- infra/docker/web.Dockerfile | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) mode change 100644 => 100755 infra/docker/nginx.conf mode change 100644 => 100755 infra/docker/web.Dockerfile diff --git a/infra/docker/nginx.conf b/infra/docker/nginx.conf old mode 100644 new mode 100755 index 34eb63aa2..cd44ef4f7 --- a/infra/docker/nginx.conf +++ b/infra/docker/nginx.conf @@ -18,16 +18,19 @@ server { } # API proxy - # Docker DNS resolver - refresh every 10s to handle container IP changes + # Use static proxy_pass with container name to avoid URI stripping issues + # that occur with variable-based proxy_pass (set $upstream ...). + # DNS resolver kept for container IP refresh on restart. resolver 127.0.0.11 valid=10s; resolver_timeout 5s; location /api/ { - set $upstream http://api:8000; - proxy_pass $upstream/api/; + proxy_pass http://xiaoxia-api-staging:8000/api/; 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_read_timeout 300s; + proxy_send_timeout 300s; proxy_request_buffering off; } @@ -36,4 +39,4 @@ server { expires 1y; add_header Cache-Control "public, immutable"; } -} \ No newline at end of file +} diff --git a/infra/docker/web.Dockerfile b/infra/docker/web.Dockerfile old mode 100644 new mode 100755 index 85c26776f..debf6aff9 --- a/infra/docker/web.Dockerfile +++ b/infra/docker/web.Dockerfile @@ -12,8 +12,9 @@ RUN npm run build # Production stage with nginx FROM docker.m.daocloud.io/library/nginx:alpine AS runner +ARG NGINX_CONF=infra/docker/nginx.conf WORKDIR /usr/share/nginx/html COPY --from=builder /app/apps/web/dist ./ -COPY infra/docker/nginx.conf /etc/nginx/conf.d/default.conf +COPY ${NGINX_CONF} /etc/nginx/conf.d/default.conf EXPOSE 80 CMD ["nginx", "-g", "daemon off;"]