{
  "id": "nginx/upstream-sent-invalid-status-line-while-reading-response-header",
  "signature": "upstream sent invalid status line while reading response header from upstream: \"HTTP/1.1 200 OK\\r\\n\" (extra characters)",
  "signature_zh": "上游发送了无效的状态行，同时从上游读取响应头：\"HTTP/1.1 200 OK\\r\\n\"（多余字符）",
  "regex": "upstream sent invalid status line while reading response header from upstream",
  "domain": "nginx",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "Upstream server sends a response with malformed status line, such as extra spaces, invalid characters, or non-standard HTTP version.",
  "root_cause_type": "generic",
  "root_cause_zh": "",
  "versions": [
    {
      "version": "nginx 1.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.25.3",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.26.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "Add proxy_set_header Host $host;",
      "why_fails": "This sets request headers, not response validation.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Increase proxy_read_timeout",
      "why_fails": "Timeout does not fix malformed response line.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    },
    {
      "action": "Restart nginx",
      "why_fails": "Restarting does not change upstream behavior.",
      "fail_rate": 1.0,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Use a custom nginx module or Lua to sanitize upstream response. Example with lua-nginx-module:\n  location / {\n      rewrite_by_lua_block {\n          -- This is a placeholder; actual sanitization would require body_filter_by_lua\n      }\n      body_filter_by_lua '\n          -- If you can modify headers, but status line is not easily modifiable in Lua\n          -- Better to fix upstream\n      ';\n      proxy_pass http://upstream;\n  }",
      "success_rate": 0.3,
      "how": "Use a custom nginx module or Lua to sanitize upstream response. Example with lua-nginx-module:\n  location / {\n      rewrite_by_lua_block {\n          -- This is a placeholder; actual sanitization would require body_filter_by_lua\n      }\n      body_filter_by_lua '\n          -- If you can modify headers, but status line is not easily modifiable in Lua\n          -- Better to fix upstream\n      ';\n      proxy_pass http://upstream;\n  }",
      "condition": "",
      "sources": []
    },
    {
      "action": "Fix the upstream application to emit a valid HTTP status line. For example, in a Python server:\n  # Ensure the response line is exactly \"HTTP/1.1 200 OK\\r\\n\"\n  response = b\"HTTP/1.1 200 OK\\r\\nContent-Length: 5\\r\\n\\r\\nhello\"\n  # Avoid extra characters or spaces after the status line",
      "success_rate": 0.95,
      "how": "Fix the upstream application to emit a valid HTTP status line. For example, in a Python server:\n  # Ensure the response line is exactly \"HTTP/1.1 200 OK\\r\\n\"\n  response = b\"HTTP/1.1 200 OK\\r\\nContent-Length: 5\\r\\n\\r\\nhello\"\n  # Avoid extra characters or spaces after the status line",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Use a custom nginx module or Lua to sanitize upstream response. Example with lua-nginx-module:\n  location / {\n      rewrite_by_lua_block {\n          -- This is a placeholder; actual sanitization would require body_filter_by_lua\n      }\n      body_filter_by_lua '\n          -- If you can modify headers, but status line is not easily modifiable in Lua\n          -- Better to fix upstream\n      ';\n      proxy_pass http://upstream;\n  }",
    "Fix the upstream application to emit a valid HTTP status line. For example, in a Python server:\n  # Ensure the response line is exactly \"HTTP/1.1 200 OK\\r\\n\"\n  response = b\"HTTP/1.1 200 OK\\r\\nContent-Length: 5\\r\\n\\r\\nhello\"\n  # Avoid extra characters or spaces after the status line"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nginx.org/en/docs/http/ngx_http_proxy_module.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.85,
  "resolvable": "partial",
  "first_seen": "2025-08-20",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}