{
  "id": "nginx/invalid-host-header-upstream",
  "signature": "upstream sent invalid host header while connecting to upstream",
  "signature_zh": "上游服务器发送了无效的 Host 头部",
  "regex": "upstream sent invalid host header",
  "domain": "nginx",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "The upstream server responded with an invalid or malformed Host header (e.g., empty, non-ASCII, or too long), causing nginx to reject it during response processing.",
  "root_cause_type": "generic",
  "root_cause_zh": "上游服务器返回了无效或格式错误的 Host 头部（例如空值、非 ASCII 字符或过长），导致 nginx 在处理响应时拒绝。",
  "versions": [
    {
      "version": "nginx 1.24.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.22.1",
      "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"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "This controls the request header sent to upstream, not the response header from upstream.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The issue is often in the upstream application logic that generates the response header.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "proxy_ignore_headers does not apply to the Host header; it applies to other headers like Cache-Control.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Fix the upstream application to return a valid Host header (e.g., ensure it's a non-empty ASCII string). For example, in a Node.js app: `res.setHeader('Host', req.headers.host || 'example.com');`",
      "success_rate": 0.9,
      "how": "Fix the upstream application to return a valid Host header (e.g., ensure it's a non-empty ASCII string). For example, in a Node.js app: `res.setHeader('Host', req.headers.host || 'example.com');`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use proxy_pass with a specific IP and set the Host header manually in nginx: `proxy_set_header Host $proxy_host;`",
      "success_rate": 0.7,
      "how": "Use proxy_pass with a specific IP and set the Host header manually in nginx: `proxy_set_header Host $proxy_host;`",
      "condition": "",
      "sources": []
    },
    {
      "action": "Inspect upstream logs to see the exact Host header being sent and sanitize it in the upstream application code.",
      "success_rate": 0.8,
      "how": "Inspect upstream logs to see the exact Host header being sent and sanitize it in the upstream application code.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Fix the upstream application to return a valid Host header (e.g., ensure it's a non-empty ASCII string). For example, in a Node.js app: `res.setHeader('Host', req.headers.host || 'example.com');`",
    "Use proxy_pass with a specific IP and set the Host header manually in nginx: `proxy_set_header Host $proxy_host;`",
    "Inspect upstream logs to see the exact Host header being sent and sanitize it in the upstream application code."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_set_header",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.82,
  "fix_success_rate": 0.85,
  "resolvable": "true",
  "first_seen": "2024-03-10",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}