nginx protocol_error ai_generated true

上游返回不支持的HTTP/2.0响应

upstream sent HTTP/2.0 response while reading response header from upstream, client: 10.0.0.5

ID: nginx/upstream-sent-http-version-not-supported

其他格式: JSON · Markdown 中文 · English
75%修复率
82%置信度
1证据数
2024-05-22首次发现

版本兼容性

版本状态引入弃用备注
nginx 1.20.0 active
nginx 1.22.1 active
nginx 1.25.0 active

根因分析

上游服务器发送了HTTP/2.0响应,但未通过ALPN协商HTTP/2,导致协议不匹配和连接失败。

English

Upstream server sent an HTTP/2.0 response to nginx that did not negotiate HTTP/2 via ALPN, causing protocol mismatch and connection failure.

generic

官方文档

https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version

解决方案

  1. Configure upstream to use HTTP/1.1 instead of HTTP/2. For example, in Apache: disable HTTP/2 module; in Node.js: set HTTP/1.1 explicitly.
  2. If upstream must use HTTP/2, place a reverse proxy like HAProxy or Caddy between nginx and the upstream that can downgrade HTTP/2 to HTTP/1.1.
  3. Ensure upstream server correctly negotiates HTTP/2 via TLS ALPN (e.g., for nginx as upstream, use 'listen 443 ssl http2;').

无效尝试

常见但无效的做法:

  1. 90% 失败

    Nginx proxy module does not support HTTP/2 as upstream protocol; setting it will cause configuration error.

  2. 95% 失败

    As of nginx 1.25.x, HTTP/2 upstream is not supported in the proxy module; this is a limitation of nginx itself.

  3. 80% 失败

    The error will recur on every request; retries do not fix the protocol mismatch.