# 上游发送了无效的 HTTP 版本

- **ID:** `nginx/upstream-sent-invalid-http-version`
- **领域:** nginx
- **类别:** protocol_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

上游服务器返回的响应中包含无法识别或格式错误的 HTTP 版本字符串（例如 HTTP/1.0、HTTP/2.0 或 HTTP/3）。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| nginx-1.24.0 | active | — | — |
| nginx-1.25.3 | active | — | — |
| nginx-1.26.0 | active | — | — |

## 解决方案

1. ```
   Set proxy_http_version to 1.1 or 2.0 in the location block to match the upstream server's expected protocol. Example:
location /api/ {
    proxy_pass http://backend;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
}
   ```
2. ```
   If the upstream is a custom or legacy server, ensure it returns a valid HTTP version string (e.g., 'HTTP/1.1 200 OK'). Check the upstream application logs for version misconfiguration.
   ```

## 无效尝试

- **** — Forcing HTTP/1.0 on a modern upstream that uses chunked encoding or keepalive will cause protocol mismatch. (60% 失败率)
- **** — The error is about the response version, not the request path. (90% 失败率)
- **** — This error is a protocol-level error, not a buffer size issue. (95% 失败率)
