From cd9c8d56abdb33182eaee4c4b259997b65e71881 Mon Sep 17 00:00:00 2001 From: wangbo Date: Fri, 31 Jul 2026 01:03:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(nginx):=20=E5=B0=86=E5=8E=9F=E7=94=9F?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B=E6=8E=A5=E5=8F=A3=E8=BD=AC=E5=8F=91=E8=87=B3?= =?UTF-8?q?=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 生产同构 Gemini 验收发现 /v1beta 请求被 Web 入口返回 405,导致请求在到达 Worker 前全部失败。补齐 /v1 和 /v1beta 原生兼容路由,沿用 API 的长请求超时、无缓冲和双上游故障切换配置。\n\n验证:使用 nginx:1.27-alpine 对完整站点配置执行 nginx -t 通过。 --- deploy/nginx/ai.51easyai.com-cluster.conf | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/deploy/nginx/ai.51easyai.com-cluster.conf b/deploy/nginx/ai.51easyai.com-cluster.conf index d3f31e1..ebae2e1 100644 --- a/deploy/nginx/ai.51easyai.com-cluster.conf +++ b/deploy/nginx/ai.51easyai.com-cluster.conf @@ -56,6 +56,26 @@ server { proxy_pass http://easyai_gateway_api; } + # Gemini and OpenAI native compatibility routes are intentionally exposed + # without the /api prefix. Keep them on the API upstream instead of allowing + # the catch-all Web location to return 405 for valid provider requests. + location ~ ^/v1(?:beta)?/ { + 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 https; + proxy_set_header Connection ""; + proxy_connect_timeout 2s; + proxy_send_timeout 3600s; + proxy_read_timeout 3600s; + proxy_request_buffering off; + proxy_buffering off; + proxy_next_upstream error timeout http_502 http_503 http_504; + proxy_next_upstream_tries 2; + proxy_pass http://easyai_gateway_api; + } + location /gateway-api/ { proxy_http_version 1.1; proxy_set_header Host $host;