From 3e29012d9c87d7f904e6446ad6446d95455b45fa Mon Sep 17 00:00:00 2001 From: RRRosmontis Date: Sat, 19 Sep 2026 01:23:37 +0800 Subject: [PATCH] =?UTF-8?q?server=5Fconfig:=20CONNECT=20=E5=87=BA=E7=AB=99?= =?UTF-8?q?=E8=B6=85=E6=97=B6=2060s=E2=86=9210s=EF=BC=8C=E5=B9=B6=E8=A1=A5?= =?UTF-8?q?=E5=85=85=E6=8E=92=E9=9A=9C=E5=8F=A3=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 实测(2026-09):目标为黑洞 IP 时,nginx 出站超时 60s > lite 客户端 15s, 表现为客户端 'read operation timed out' 而非 502,形似代理卡死,实为超时错配。 改为 10s 后黑洞目标 10.2s 返回、正常目标 0.4-0.7s 不受影响(五节点已生效)。 README 新增 5.6 节:三个超时的口径 + 'CONNECT 502' 的排查顺序 (先判断目标是否本身不可达 → 再看 nginx 错误类型 → 最后才怀疑 CONNECT 模块), 并建议客户端日志记录原始域名(案例:Dropbox 旧 IP 失效导致误判)。 --- server_config/README.md | 25 +++++++++++++++++++++++++ server_config/nginx/nginx.conf | 8 ++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/server_config/README.md b/server_config/README.md index c869ce3..4ed29da 100644 --- a/server_config/README.md +++ b/server_config/README.md @@ -310,6 +310,31 @@ magic 地址 → `127.0.0.1:15201`,其余 CONNECT 走 `$connect_addr` 默认 请求头 `| isConnect u8 | ATYP u8 | address | port u16be |`, connect 模式帧 `| length u16be | data |`,non-connect 帧每帧自带目标地址。 +### 5.6 CONNECT 超时口径(避免客户端"卡死") + +三个超时要按"客户端最没耐心"来配: + +| 项 | 值 | 说明 | +|---|---|---| +| `proxy_connect_connect_timeout` | **10s** | 出站连接目标;须 < 客户端超时(lite 客户端 15s) | +| `proxy_connect_read_timeout` / `send_timeout` | 10m | 隧道空闲超时(UoT 长连接需要;注意与 data_timeout 同槽位) | + +**典型故障**:目标 IP 是黑洞(不发 RST)时,若 nginx 出站超时设 60s 而客户端 15s 超时, +客户端会表现为 `The read operation timed out` 而不是收到 502 —— 看起来像"代理卡死", +实际是超时错配。2026-09 实测:改为 10s 后,黑洞目标从 >25s 降至 10.2s 返回, +正常目标(0.4~0.7s)不受影响。 + +**排查"CONNECT 502"的正确顺序**(重要): +1. 先看目标是否**本身就不可达**——从多个网络(国内/日本/美国/香港)实测该 IP:端口, + 若都失败则是目标问题(服务下线/过期 IP/黑洞),不是代理问题; +2. 再看 nginx error.log:`Connection refused` / `timed out` / `Network is unreachable` + 分别对应目标拒绝、目标黑洞、路由不可达; +3. 最后才怀疑 CONNECT 模块本身。 + +> 客户端日志只记 IP 不记域名时,无法判断"是不是 DNS 过期解析"。 +> 建议客户端日志同时记录原始域名(实测案例:某 Dropbox 旧 IP 已失效, +> 域名现已解析到其它地址,客户端仍在拨旧 IP)。 + ## 6. sing-box(VLESS+REALITY / Shadowsocks) ### 6.1 安装 diff --git a/server_config/nginx/nginx.conf b/server_config/nginx/nginx.conf index 75c123c..9f60949 100644 --- a/server_config/nginx/nginx.conf +++ b/server_config/nginx/nginx.conf @@ -58,7 +58,9 @@ http { proxy_connect; proxy_connect_allow all; proxy_connect_address $rrpp_uot_connect_address; - proxy_connect_connect_timeout 60s; + # 出站连接超时须小于客户端超时(lite 客户端 15s): + # 目标黑洞时快速返回 502,避免客户端"read operation timed out"干等 + proxy_connect_connect_timeout 10s; # 注:此模块版本 proxy_connect_data_timeout 与 proxy_connect_read_timeout # 写同一字段(同时配置报 duplicate),长连接超时用 read/send timeout 设置 proxy_connect_read_timeout 10m; @@ -109,7 +111,9 @@ http { proxy_connect; proxy_connect_allow all; proxy_connect_address $rrpp_uot_connect_address; - proxy_connect_connect_timeout 60s; + # 出站连接超时须小于客户端超时(lite 客户端 15s): + # 目标黑洞时快速返回 502,避免客户端"read operation timed out"干等 + proxy_connect_connect_timeout 10s; # 注:此模块版本 proxy_connect_data_timeout 与 proxy_connect_read_timeout # 写同一字段(同时配置报 duplicate),长连接超时用 read/send timeout 设置 proxy_connect_read_timeout 10m;