# 上游返回HTTP/1.0响应

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

## 根因

上游服务器发送了HTTP/1.0响应，而nginx期望HTTP/1.1或更高版本，通常由后端配置错误或遗留应用引起。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| nginx 1.18.0 | active | — | — |
| nginx 1.20.2 | active | — | — |
| nginx 1.24.0 | active | — | — |

## 解决方案

1. ```
   Configure upstream to use HTTP/1.1 (e.g., for Node.js: set 'keepAliveTimeout' and HTTP version; for Apache: ensure 'SetEnv nokeepalive 0' is not set).
   ```
2. ```
   In nginx, set proxy_http_version to 1.1 and ensure proxy_set_header Connection ''; to handle keep-alive properly:
proxy_http_version 1.1;
proxy_set_header Connection '';
   ```
3. ```
   If upstream is a legacy system that only supports HTTP/1.0, consider using a middleware proxy that upgrades the protocol.
   ```

## 无效尝试

- **** — This forces nginx to speak HTTP/1.0 to upstream, but may cause other issues like missing chunked transfer encoding; the error remains if upstream still sends HTTP/1.0. (60% 失败率)
- **** — Buffering does not change the protocol version; the error will still appear in logs and may cause intermittent failures. (75% 失败率)
- **** — Restarting does not change the protocol version the upstream uses; misconfiguration persists. (85% 失败率)
