nginx protocol_error ai_generated true

upstream sent HTTP/1.1 response while reading response header from upstream

ID: nginx/upstream-sent-http-1-1-response-while-reading-response-header

Also available as: JSON · Markdown · 中文
85%Fix Rate
88%Confidence
1Evidence
2023-11-15First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
nginx 1.20.x active
nginx 1.22.x active
nginx 1.24.x active
Apache 2.4.x active
Gunicorn 20.x active

Root Cause

Upstream server returns HTTP/1.1 response but Nginx is configured to expect HTTP/1.0, causing header parsing mismatch.

generic

中文

上游服务器返回HTTP/1.1响应,但Nginx配置为期望HTTP/1.0,导致头部解析不匹配。

Official Documentation

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

Workarounds

  1. 85% success Set proxy_http_version to 1.1 in the location block: proxy_http_version 1.1;
    Set proxy_http_version to 1.1 in the location block: proxy_http_version 1.1;
  2. 70% success Configure upstream to return HTTP/1.0 responses if possible.
    Configure upstream to return HTTP/1.0 responses if possible.

中文步骤

  1. 在location块中设置proxy_http_version为1.1:proxy_http_version 1.1;
  2. 如果可能,配置上游返回HTTP/1.0响应。

Dead Ends

Common approaches that don't work:

  1. Disabling HTTP/1.1 support on upstream 60% fail

    Upstream servers often default to HTTP/1.1; disabling may break functionality.

  2. Increasing proxy buffer sizes 80% fail

    Buffer size does not affect protocol version negotiation.

  3. Adding proxy_set_header Host $host 90% fail

    Header manipulation doesn't change protocol version.