# 上游在读取响应头时发送了HTTP/1.0响应

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

## 根因

上游服务器以HTTP/1.0而非HTTP/1.1响应，导致nginx拒绝或以不同方式处理头部。

## 版本兼容性

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

## 解决方案

1. ```
   Configure the upstream server to use HTTP/1.1. For example, in Apache HTTPD as upstream, set:

<IfModule mod_remoteip.c>
    RemoteIPHeader X-Forwarded-For
    RemoteIPInternalProxy 10.0.0.0/8
</IfModule>

And ensure mod_proxy_http uses HTTP/1.1 by default.
   ```
2. ```
   Add proxy_http_version 1.1; and proxy_set_header Connection ""; to nginx location block:

location / {
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_pass http://upstream;
}
   ```
3. ```
   If upstream cannot be changed, use nginx as a reverse proxy with proxy_pass http://upstream; and set proxy_http_version 1.0; to match upstream behavior:

location / {
    proxy_http_version 1.0;
    proxy_set_header Connection close;
    proxy_pass http://upstream;
}
   ```

## 无效尝试

- **** — This forces nginx to use HTTP/1.0 to upstream, but the upstream might still send HTTP/1.0 responses, and nginx may still reject them if it expects HTTP/1.1. (70% 失败率)
- **** — The issue is not buffer size but protocol version mismatch; buffer size does not change the response version. (90% 失败率)
- **** — Keepalive settings affect connection reuse, not the HTTP version of responses. (80% 失败率)
