{
  "id": "nginx/upstream-sent-http-2-0-response-while-reading-response-header-from-upstream",
  "signature": "upstream sent HTTP/2.0 response while reading response header from upstream",
  "signature_zh": "上游在读取响应头时发送了HTTP/2.0响应",
  "regex": "upstream sent HTTP/2.0 response while reading response header from upstream",
  "domain": "nginx",
  "category": "protocol_error",
  "subcategory": null,
  "root_cause": "Upstream server responded with HTTP/2 (HTTP/2.0) but nginx is configured to use HTTP/1.x for proxying, causing a protocol mismatch.",
  "root_cause_type": "generic",
  "root_cause_zh": "上游服务器以HTTP/2（HTTP/2.0）响应，但nginx配置为使用HTTP/1.x进行代理，导致协议不匹配。",
  "versions": [
    {
      "version": "nginx 1.18.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.20.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "nginx 1.22.0",
      "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": "If the upstream only supports HTTP/2, forcing HTTP/1.1 will not change the upstream's response; the upstream will still send HTTP/2 responses.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Buffer size does not affect protocol version negotiation.",
      "fail_rate": 0.95,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "These headers are for WebSocket upgrades, not HTTP version negotiation.",
      "fail_rate": 0.85,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Configure nginx to proxy using HTTP/2 by setting proxy_http_version 2.0; (requires nginx compiled with HTTP/2 support and ngx_http_v2_module):\n\nlocation / {\n    proxy_http_version 2.0;\n    proxy_pass https://upstream;  # Note: HTTPS required for HTTP/2\n}",
      "success_rate": 0.8,
      "how": "Configure nginx to proxy using HTTP/2 by setting proxy_http_version 2.0; (requires nginx compiled with HTTP/2 support and ngx_http_v2_module):\n\nlocation / {\n    proxy_http_version 2.0;\n    proxy_pass https://upstream;  # Note: HTTPS required for HTTP/2\n}",
      "condition": "",
      "sources": []
    },
    {
      "action": "If the upstream is an HTTP/2 server, configure it to also support HTTP/1.1. For example, in a Node.js server using http2 module:\n\nconst http2 = require('http2');\nconst http = require('http');\n\nconst server = http2.createServer();\nserver.on('stream', (stream, headers) => {\n    stream.respond({ ':status': 200 });\n    stream.end('OK');\n});\nserver.listen(8080);\n\nAdd an HTTP/1.1 listener on a different port if needed.",
      "success_rate": 0.75,
      "how": "If the upstream is an HTTP/2 server, configure it to also support HTTP/1.1. For example, in a Node.js server using http2 module:\n\nconst http2 = require('http2');\nconst http = require('http');\n\nconst server = http2.createServer();\nserver.on('stream', (stream, headers) => {\n    stream.respond({ ':status': 200 });\n    stream.end('OK');\n});\nserver.listen(8080);\n\nAdd an HTTP/1.1 listener on a different port if needed.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Use a load balancer like HAProxy that can convert HTTP/2 to HTTP/1.1:\n\nfrontend http-in\n    bind *:80\n    default_backend servers\n\nbackend servers\n    server upstream1 10.0.0.1:8080 proto h2\n\nHAProxy can terminate HTTP/2 and forward as HTTP/1.1 to nginx.",
      "success_rate": 0.7,
      "how": "Use a load balancer like HAProxy that can convert HTTP/2 to HTTP/1.1:\n\nfrontend http-in\n    bind *:80\n    default_backend servers\n\nbackend servers\n    server upstream1 10.0.0.1:8080 proto h2\n\nHAProxy can terminate HTTP/2 and forward as HTTP/1.1 to nginx.",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Configure nginx to proxy using HTTP/2 by setting proxy_http_version 2.0; (requires nginx compiled with HTTP/2 support and ngx_http_v2_module):\n\nlocation / {\n    proxy_http_version 2.0;\n    proxy_pass https://upstream;  # Note: HTTPS required for HTTP/2\n}",
    "If the upstream is an HTTP/2 server, configure it to also support HTTP/1.1. For example, in a Node.js server using http2 module:\n\nconst http2 = require('http2');\nconst http = require('http');\n\nconst server = http2.createServer();\nserver.on('stream', (stream, headers) => {\n    stream.respond({ ':status': 200 });\n    stream.end('OK');\n});\nserver.listen(8080);\n\nAdd an HTTP/1.1 listener on a different port if needed.",
    "Use a load balancer like HAProxy that can convert HTTP/2 to HTTP/1.1:\n\nfrontend http-in\n    bind *:80\n    default_backend servers\n\nbackend servers\n    server upstream1 10.0.0.1:8080 proto h2\n\nHAProxy can terminate HTTP/2 and forward as HTTP/1.1 to nginx."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://nginx.org/en/docs/http/ngx_http_v2_module.html",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.85,
  "fix_success_rate": 0.8,
  "resolvable": "partial",
  "first_seen": "2024-06-25",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}