解决 Envoy / Istio 报错 upstream connect error or disconnect/reset before headers
分析 Envoy 反向代理报 upstream connect error 诱因,详解 cluster 端口配置、mTLS 严格模式与超时参数。
问题现象
通过 Envoy 网关或 Istio Service Mesh 访问后端时返回 503:
upstream connect error or disconnect/reset before headers. reset reason: connection termination
触发根因
- 后端容器端口协议不匹配:Envoy 配置了 HTTP/2 协议(
h2),而后端应用仅支持 HTTP/1.1,协商破裂触发连接终止。 - Istio PeerAuthentication 启用了 STRICT 严格双向 TLS,而客户端发送的是明文流量。
解决方案
方案一:在 Envoy Cluster 中显式指定协议或使用 auto_http
clusters:
- name: backend_service
connect_timeout: 5s
type: STRICT_DNS
typed_extension_protocol_options:
envoy.extensions.upstreams.http.v3.HttpProtocolOptions:
"@type": type.googleapis.com/envoy.extensions.upstreams.http.v3.HttpProtocolOptions
use_downstream_protocol_config: {} # 自动继承下游协议
验证方法
重新发起网关调用,HTTP 握手顺畅建立,请求稳定返回 200。


