nginx
protocol_error
ai_generated
true
上游发送了无效的 HTTP 版本
upstream sent invalid HTTP version while reading response header from upstream
ID: nginx/upstream-sent-invalid-http-version
80%修复率
85%置信度
1证据数
2024-03-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| nginx-1.24.0 | active | — | — | — |
| nginx-1.25.3 | active | — | — | — |
| nginx-1.26.0 | active | — | — | — |
根因分析
上游服务器返回的响应中包含无法识别或格式错误的 HTTP 版本字符串(例如 HTTP/1.0、HTTP/2.0 或 HTTP/3)。
English
The upstream server returns a response with an unrecognized or malformed HTTP version string (e.g., HTTP/1.0, HTTP/2.0, or HTTP/3).
官方文档
https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass解决方案
-
Set proxy_http_version to 1.1 or 2.0 in the location block to match the upstream server's expected protocol. Example: location /api/ { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Connection ""; } -
If the upstream is a custom or legacy server, ensure it returns a valid HTTP version string (e.g., 'HTTP/1.1 200 OK'). Check the upstream application logs for version misconfiguration.
无效尝试
常见但无效的做法:
-
60% 失败
Forcing HTTP/1.0 on a modern upstream that uses chunked encoding or keepalive will cause protocol mismatch.
-
90% 失败
The error is about the response version, not the request path.
-
95% 失败
This error is a protocol-level error, not a buffer size issue.