nginx protocol_error ai_generated true

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

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

Also available as: JSON · Markdown · 中文
80%Fix Rate
83%Confidence
1Evidence
2023-06-20First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
nginx 1.18.0 active
nginx 1.20.2 active
nginx 1.24.0 active

Root Cause

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

中文

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

Official Documentation

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

Workarounds

  1. 85% success 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).
    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. 75% success 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 '';
    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. 40% success If upstream is a legacy system that only supports HTTP/1.0, consider using a middleware proxy that upgrades the protocol.
    If upstream is a legacy system that only supports HTTP/1.0, consider using a middleware proxy that upgrades the protocol.

中文步骤

  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.

Dead Ends

Common approaches that don't work:

  1. 60% fail

    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% fail

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

  3. 85% fail

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