nginx
protocol_error
ai_generated
true
上游发送了无效的状态行,从上游读取响应头时,客户端:10.0.0.1,服务器:example.com
upstream sent invalid status line while reading response header from upstream, client: 10.0.0.1, server: example.com
ID: nginx/upstream-sent-invalid-status-line-empty
76%修复率
84%置信度
1证据数
2023-11-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| nginx 1.18.0 | active | — | — | — |
| nginx 1.20.1 | active | — | — | — |
| nginx 1.22.0 | active | — | — | — |
| nginx 1.24.0 | active | — | — | — |
根因分析
上游服务器发送了格式错误的 HTTP 状态行(例如,空行或缺少 HTTP 版本),导致 nginx 无法解析响应。
English
Upstream server sends a malformed HTTP status line (e.g., empty or missing HTTP version), causing nginx to fail parsing the response.
官方文档
https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass解决方案
-
Fix the upstream application to return a valid HTTP status line. For example, in a Python WSGI app, ensure the application returns a proper start line: def application(environ, start_response): status = '200 OK' headers = [('Content-Type', 'text/plain')] start_response(status, headers) return [b'Hello World'] Check for missing or empty status strings in custom servers. -
Use nginx's proxy_pass with a rewrite to a different upstream that sanitizes responses, or place a reverse proxy like Varnish in front of the misbehaving upstream to normalize responses.
无效尝试
常见但无效的做法:
-
Set proxy_http_version 1.1;
90% 失败
The error is about a malformed status line, not the HTTP version. Changing proxy version does not fix upstream's invalid output.
-
Increase proxy_read_timeout
95% 失败
Timeout does not affect the format of the response; the upstream is responding, but with invalid data.
-
Add proxy_buffering off;
92% 失败
Buffering affects how nginx reads the response body, not the status line parsing in the header.