nginx protocol_error ai_generated true

上游返回HTTP/1.0响应

upstream sent HTTP/1.0 response while reading response header from upstream, client: 192.168.1.10

ID: nginx/upstream-sent-http-1-0

其他格式: JSON · Markdown 中文 · English
80%修复率
83%置信度
1证据数
2023-06-20首次发现

版本兼容性

版本状态引入弃用备注
nginx 1.18.0 active
nginx 1.20.2 active
nginx 1.24.0 active

根因分析

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

English

Upstream server sent an HTTP/1.0 response when nginx expected HTTP/1.1 or higher, often due to a misconfigured backend or legacy application.

generic

官方文档

https://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_http_version

解决方案

  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.

无效尝试

常见但无效的做法:

  1. 60% 失败

    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.

  2. 75% 失败

    Buffering does not change the protocol version; the error will still appear in logs and may cause intermittent failures.

  3. 85% 失败

    Restarting does not change the protocol version the upstream uses; misconfiguration persists.