nginx protocol_error ai_generated true

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

Also available as: JSON · Markdown · 中文
75%Fix Rate
82%Confidence
1Evidence
2024-05-22First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
nginx 1.20.0 active
nginx 1.22.1 active
nginx 1.25.0 active

Root Cause

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

中文

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

Official Documentation

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

Workarounds

  1. 85% success 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.
    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. 60% success 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.
    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. 70% success Ensure upstream server correctly negotiates HTTP/2 via TLS ALPN (e.g., for nginx as upstream, use 'listen 443 ssl http2;').
    Ensure upstream server correctly negotiates HTTP/2 via TLS ALPN (e.g., for nginx as upstream, use 'listen 443 ssl http2;').

中文步骤

  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;').

Dead Ends

Common approaches that don't work:

  1. 90% fail

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

  2. 95% fail

    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% fail

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