{
  "id": "nginx/upstream-sent-invalid-transfer-encoding",
  "signature": "upstream sent invalid transfer-encoding while reading response body from upstream",
  "signature_zh": "上游发送了无效的 transfer-encoding",
  "regex": "upstream sent invalid transfer-encoding while reading response body from upstream",
  "domain": "nginx",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "The upstream server returns a response with a Transfer-Encoding header that is malformed or conflicting with Content-Length, causing nginx to reject the response.",
  "root_cause_type": "generic",
  "root_cause_zh": "上游服务器返回的响应中包含格式错误或与 Content-Length 冲突的 Transfer-Encoding 头部，导致 nginx 拒绝该响应。",
  "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": "",
      "why_fails": "HTTP/1.0 cannot use chunked encoding; the upstream must send Content-Length instead.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This only affects connection persistence, not the encoding of the response body.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Buffer sizes affect data handling, not header validation.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Fix the upstream application to send a valid Transfer-Encoding header. For example, in a Node.js Express app, ensure you use res.end() properly to avoid conflicting headers:\napp.get('/data', (req, res) => {\n    res.set('Transfer-Encoding', 'chunked');\n    res.write('Hello');\n    res.end();\n});\n# Or use a library like compression for proper encoding.",
      "success_rate": 0.85,
      "how": "Fix the upstream application to send a valid Transfer-Encoding header. For example, in a Node.js Express app, ensure you use res.end() properly to avoid conflicting headers:\napp.get('/data', (req, res) => {\n    res.set('Transfer-Encoding', 'chunked');\n    res.write('Hello');\n    res.end();\n});\n# Or use a library like compression for proper encoding.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the upstream is a legacy server, force nginx to use HTTP/1.1 and disable buffering to work around the issue:\nlocation / {\n    proxy_http_version 1.1;\n    proxy_set_header Connection \"\";\n    proxy_buffering off;\n    proxy_pass http://upstream;\n}",
      "success_rate": 0.8,
      "how": "If the upstream is a legacy server, force nginx to use HTTP/1.1 and disable buffering to work around the issue:\nlocation / {\n    proxy_http_version 1.1;\n    proxy_set_header Connection \"\";\n    proxy_buffering off;\n    proxy_pass http://upstream;\n}",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Fix the upstream application to send a valid Transfer-Encoding header. For example, in a Node.js Express app, ensure you use res.end() properly to avoid conflicting headers:\napp.get('/data', (req, res) => {\n    res.set('Transfer-Encoding', 'chunked');\n    res.write('Hello');\n    res.end();\n});\n# Or use a library like compression for proper encoding.",
    "If the upstream is a legacy server, force nginx to use HTTP/1.1 and disable buffering to work around the issue:\nlocation / {\n    proxy_http_version 1.1;\n    proxy_set_header Connection \"\";\n    proxy_buffering off;\n    proxy_pass http://upstream;\n}"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.84,
  "fix_success_rate": 0.82,
  "resolvable": "true",
  "first_seen": "2024-04-22",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}