nginx protocol_error ai_generated true

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

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

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

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
nginx 1.24.0 active
nginx 1.22.1 active
nginx 1.20.2 active

Root Cause

Upstream server returns HTTP/1.0 response when nginx expects HTTP/1.1 or HTTP/2, causing header parsing failure.

generic

中文

上游服务器返回 HTTP/1.0 响应,而 nginx 期望 HTTP/1.1 或 HTTP/2,导致头部解析失败。

Official Documentation

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

Workarounds

  1. 85% success Set 'proxy_http_version 1.1;' in the location block and ensure upstream supports HTTP/1.1. Example: location /api { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Connection ''; }
    Set 'proxy_http_version 1.1;' in the location block and ensure upstream supports HTTP/1.1. Example: location /api { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Connection ''; }
  2. 75% success If upstream cannot be changed, add 'proxy_set_header Connection close;' to force connection closure after each request.
    If upstream cannot be changed, add 'proxy_set_header Connection close;' to force connection closure after each request.

中文步骤

  1. Set 'proxy_http_version 1.1;' in the location block and ensure upstream supports HTTP/1.1. Example: location /api { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Connection ''; }
  2. If upstream cannot be changed, add 'proxy_set_header Connection close;' to force connection closure after each request.

Dead Ends

Common approaches that don't work:

  1. 70% fail

    Buffer size is not the issue; the protocol version mismatch is unrelated to buffer allocation.

  2. 60% fail

    This forces HTTP/1.0 which may cause other issues; the real fix is to upgrade the upstream.