Keep-alive to upstreams is now default in NGINX 1.29.7

https://blog.nginx.org/ 2026-10-28 06:10:42 累计浏览 111 次

Before version 1.29.7, NGINX used HTTP/1.0 by default for connecting to HTTP upstream servers. This older version of the protocol does not have the capability of HTTP persistent connections, commonly known as “keep-alive.”

Keep-alive reduces the number of handshakes, reduces latency, and reduces time to first byte for most regular web applications. In order to enable HTTP/1.1 and switch on the keep-alive behavior for upstream servers, operators added several directives in their configuration files. In many cases, this was forgotten, and multiple parts of web applications ended up working slower than expected.

Commonly used configuration snippet:

proxy_http_version 1.1;
proxy_set_header Connection "";

With version 1.29.7, released in March 2026, we changed the default behavior of HTTP proxying to use HTTP/1.1 with keep-alive.

The above-mentioned configuration lines are now no longer needed.

Downgrading upstream connections to HTTP/1.0

If your backend servers specifically require HTTP/1.0, you can use the following configuration lines in the relevant location contexts:

proxy_http_version 1.0;
proxy_set_header Connection "Close";

New keepalive directive parameter “local”

When the same upstream block is referenced across multiple locations or server blocks, requests from those different locations may be multiplexed over a single TCP connection to the upstream.

This behavior is controlled by the “local” parameter of the keepalive directive in the upstream context.

Due to backwards compatibility with previous NGINX versions, the default behavior of this parameter is not obvious. Please read through the following three options:

1. Default behavior when no keepalive directive is present: cached upstream connections are not shared between locations.

2. Behavior when the keepalive directive is present without the “local” parameter: cached upstream connections are shared between locations. This behavior is consistent with previous versions of NGINX:

upstream your-upstream-name {
  keepalive 32;
....
}

3. Behavior when the keepalive directive is present with the “local” parameter: this is the most explicit setting, with a predictable outcome.

upstream your-upstream-name {
  keepalive 32 local;
....
}

Refer to the official documentation for more details:

– https://nginx.org/en/docs/http/ngx_http_proxy_module.html

– https://nginx.org/en/docs/http/ngx_http_upstream_module.html

Use the “Discussions” section of our official repository for feedback: https://github.com/nginx/nginx/discussions

Follow the upcoming code changes and development conversations: https://github.com/nginx/nginx/pulls

NGINX Community Forum

同分类推荐文章

  1. NGINX 1.31.7: Native GeoIP2 support, HTTP/2 priorities, and QUIC improvements (2026-11-13 23:40:02)
  2. 说说广场 API 0.31.0 版的调用代码说明 (2026-11-13 19:10:02)
  3. NGINX Routing on HTTP Request Body (2026-10-27 14:10:42)

查看更多 后端 文章 →

建议继续学习

  1. 配置Nginx+uwsgi更方便地部署python应用 (累计阅读 109,257)
  2. 搜狐闪电邮箱的 Nginx/Postfix 使用模式 (累计阅读 34,259)
  3. 记录一个软中断问题 (累计阅读 17,393)
  4. 解析nginx负载均衡 (累计阅读 17,001)
  5. HTTP协议Keep-Alive模式详解 (累计阅读 12,433)
  6. Nginx模块开发入门 (累计阅读 11,531)
  7. server日志的路径分析 (累计阅读 11,501)
  8. Cacti 添加 Nginx 监控 (累计阅读 11,297)
  9. 检查nginx配置,重载配置以及重启的方法 (累计阅读 11,292)
  10. fsockopen 异步处理 (累计阅读 10,807)