nginx protocol_error ai_generated true

上游在读取响应头时发送了 HTTP/1.0 响应,客户端:10.0.0.5

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

其他格式: JSON · Markdown 中文 · English
82%修复率
85%置信度
1证据数
2023-11-15首次发现

版本兼容性

版本状态引入弃用备注
nginx 1.24.0 active
nginx 1.22.1 active
nginx 1.20.2 active

根因分析

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

English

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

generic

官方文档

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

解决方案

  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.

无效尝试

常见但无效的做法:

  1. 70% 失败

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

  2. 60% 失败

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