fix: 永久修复 nginx proxy_pass 配置
Deploy / Build Production Runtime Images (push) Has been skipped
Deploy / Deploy Production (push) Has been skipped
Deploy / Production Browser E2E (push) Has been skipped
Tests / lint (pull_request) Failing after 143h18m2s
Tests / test (pull_request) Failing after 143h18m2s
CI/CD Pipeline / Frontend Lint (pull_request) Failing after 143h18m31s
CI/CD Pipeline / Validate Code Quality And Tests (pull_request) Failing after 143h18m37s
Deploy / Deploy Staging (push) Failing after 143h19m29s
CI/CD Pipeline / Frontend Lint (push) Failing after 143h19m55s
CI/CD Pipeline / Validate Code Quality And Tests (push) Failing after 143h20m2s

- 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 已确认无需修改
This commit is contained in:
xiaoxia
2026-07-03 13:34:12 +08:00
parent 22ef893b6b
commit 22c1085c4b
2 changed files with 9 additions and 5 deletions
Regular → Executable
+7 -4
View File
@@ -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";
}
}
}
Regular → Executable
+2 -1
View File
@@ -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;"]