{
  "id": "nginx/upstream-sent-invalid-header",
  "signature": "upstream sent invalid header while reading response header from upstream",
  "signature_zh": "上游发送无效头部",
  "regex": "upstream sent invalid header while reading response header from upstream",
  "domain": "nginx",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "Upstream server returned a malformed or invalid HTTP header that nginx cannot parse, often due to a backend application crash or misconfiguration.",
  "root_cause_type": "generic",
  "root_cause_zh": "上游服务器返回了格式错误或无效的HTTP头部，nginx无法解析，通常由后端应用崩溃或配置错误引起。",
  "versions": [
    {
      "version": "nginx 1.18.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.20.2",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error is not about buffer size but about header validity; increasing buffers masks the issue but backend still sends invalid data.",
      "fail_rate": 0.65,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Restarting nginx does not fix the upstream application that generates invalid headers.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Disabling buffering may change behavior but does not correct invalid headers from upstream.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Check upstream application logs for errors (e.g., PHP-FPM logs, uWSGI logs). Fix the application code that sends malformed headers.",
      "success_rate": 0.85,
      "how": "Check upstream application logs for errors (e.g., PHP-FPM logs, uWSGI logs). Fix the application code that sends malformed headers.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Add a custom error page or proxy_intercept_errors on; for example:\nserver {\n    proxy_intercept_errors on;\n    error_page 502 /502.html;\n}\nThis hides the error from clients but does not fix the root cause.",
      "success_rate": 0.3,
      "how": "Add a custom error page or proxy_intercept_errors on; for example:\nserver {\n    proxy_intercept_errors on;\n    error_page 502 /502.html;\n}\nThis hides the error from clients but does not fix the root cause.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Configure nginx to ignore invalid headers by setting 'proxy_ignore_headers X-Accel-Redirect;' if the invalid header is non-critical, but prefer fixing upstream.",
      "success_rate": 0.5,
      "how": "Configure nginx to ignore invalid headers by setting 'proxy_ignore_headers X-Accel-Redirect;' if the invalid header is non-critical, but prefer fixing upstream.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Check upstream application logs for errors (e.g., PHP-FPM logs, uWSGI logs). Fix the application code that sends malformed headers.",
    "Add a custom error page or proxy_intercept_errors on; for example:\nserver {\n    proxy_intercept_errors on;\n    error_page 502 /502.html;\n}\nThis hides the error from clients but does not fix the root cause.",
    "Configure nginx to ignore invalid headers by setting 'proxy_ignore_headers X-Accel-Redirect;' if the invalid header is non-critical, but prefer fixing upstream."
  ],
  "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.85,
  "fix_success_rate": 0.78,
  "resolvable": "true",
  "first_seen": "2023-03-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}