nginx protocol_error ai_generated true

上游发送了HTTP/1.1响应,而读取响应头时预期为HTTP/1.0

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

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

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

版本兼容性

版本状态引入弃用备注
nginx 1.20.x active
nginx 1.22.x active
nginx 1.24.x active
Apache 2.4.x active
Gunicorn 20.x active

根因分析

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

English

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

generic

官方文档

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

解决方案

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

无效尝试

常见但无效的做法:

  1. Disabling HTTP/1.1 support on upstream 60% 失败

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

  2. Increasing proxy buffer sizes 80% 失败

    Buffer size does not affect protocol version negotiation.

  3. Adding proxy_set_header Host $host 90% 失败

    Header manipulation doesn't change protocol version.