nginx
protocol_error
ai_generated
true
upstream sent invalid status line while reading response header from upstream
ID: nginx/upstream-sent-invalid-status-line
87%Fix Rate
84%Confidence
1Evidence
2024-04-05First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| nginx/1.24.0 | active | — | — | — |
| nginx/1.22.1 | active | — | — | — |
Root Cause
Upstream server returned an HTTP status line that does not conform to RFC 7230 (e.g., missing HTTP version, malformed status code).
generic中文
上游服务器返回的 HTTP 状态行不符合 RFC 7230(例如缺少 HTTP 版本、状态码格式错误)。
Official Documentation
https://nginx.org/en/docs/http/ngx_http_upstream_module.htmlWorkarounds
-
95% success Fix upstream server to return valid HTTP status line (e.g., in Python: ensure response starts with 'HTTP/1.1 200 OK\r\n'). Example using Flask: return 'OK', 200, {'Content-Type': 'text/plain'}
Fix upstream server to return valid HTTP status line (e.g., in Python: ensure response starts with 'HTTP/1.1 200 OK\r\n'). Example using Flask: return 'OK', 200, {'Content-Type': 'text/plain'} -
70% success Use a custom upstream module or script to sanitize response before nginx processes it (e.g., using lua-nginx-module: content_by_lua_block { ngx.say('OK') })
Use a custom upstream module or script to sanitize response before nginx processes it (e.g., using lua-nginx-module: content_by_lua_block { ngx.say('OK') }) -
75% success Add proxy_http_version 1.0; to force HTTP/1.0 and expect simpler status line.
Add proxy_http_version 1.0; to force HTTP/1.0 and expect simpler status line.
中文步骤
Fix upstream server to return valid HTTP status line (e.g., in Python: ensure response starts with 'HTTP/1.1 200 OK\r\n'). Example using Flask: return 'OK', 200, {'Content-Type': 'text/plain'}Use a custom upstream module or script to sanitize response before nginx processes it (e.g., using lua-nginx-module: content_by_lua_block { ngx.say('OK') })Add proxy_http_version 1.0; to force HTTP/1.0 and expect simpler status line.
Dead Ends
Common approaches that don't work:
-
80% fail
Trailing slash affects URI normalization, not the status line format from upstream.
-
85% fail
Buffering does not affect header parsing; nginx always parses the status line.
-
90% fail
This clears response headers, not the status line itself.