1
0
mirror of https://github.com/thib8956/nginx-proxy synced 2025-02-24 01:38:15 +00:00

feat: enable keepalive by default

This commit is contained in:
Nicolas Duchon 2024-11-25 09:16:57 +01:00
parent d7acd931a3
commit 52ffab1ce6
3 changed files with 4 additions and 8 deletions

View File

@ -317,11 +317,7 @@ services:
``` ```
### Upstream Server HTTP Keep-Alive Support ### Upstream Server HTTP Keep-Alive Support
By default `nginx-proxy` will enable HTTP keep-alive between itself and backend server(s) and set the maximum number of idle connections to twice the number of servers listed in the corresponding `upstream{}` block, [per nginx recommendation](https://www.nginx.com/blog/avoiding-top-10-nginx-configuration-mistakes/#no-keepalives). To manually set the maximum number of idle connections or disable HTTP keep-alive entirely, use the `com.github.nginx-proxy.nginx-proxy.keepalive` label on the server's container (setting it to `disabled` will disable HTTP keep-alive).
> **Warning**
> This feature is experimental. The behavior may change (or the feature may be removed entirely) without warning in a future release, even if the release is not a new major version. If you use this feature, or if you would like to use this feature but you require changes to it first, please [provide feedback in #2194](https://github.com/nginx-proxy/nginx-proxy/discussions/2194). Once we have collected enough feedback we will promote this feature to officially supported.
To enable HTTP keep-alive between `nginx-proxy` and backend server(s), set the `com.github.nginx-proxy.nginx-proxy.keepalive` label on the server's container either to `auto` or to the desired maximum number of idle connections. The `auto` setting will dynamically set the maximum number of idle connections to twice the number of servers listed in the corresponding `upstream{}` block, [per nginx recommendation](https://www.nginx.com/blog/avoiding-top-10-nginx-configuration-mistakes/#no-keepalives).
See the [nginx keepalive documentation](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive) and the [Docker label documentation](https://docs.docker.com/config/labels-custom-metadata/) for details. See the [nginx keepalive documentation](https://nginx.org/en/docs/http/ngx_http_upstream_module.html#keepalive) and the [Docker label documentation](https://docs.docker.com/config/labels-custom-metadata/) for details.

View File

@ -655,7 +655,7 @@ proxy_set_header Proxy "";
{{- $network_tag := groupByKeys $vpath_containers "Env.NETWORK_ACCESS" | first | default "external" }} {{- $network_tag := groupByKeys $vpath_containers "Env.NETWORK_ACCESS" | first | default "external" }}
{{- $loadbalance := groupByLabel $vpath_containers "com.github.nginx-proxy.nginx-proxy.loadbalance" | keys | first }} {{- $loadbalance := groupByLabel $vpath_containers "com.github.nginx-proxy.nginx-proxy.loadbalance" | keys | first }}
{{- $keepalive := groupByLabel $vpath_containers "com.github.nginx-proxy.nginx-proxy.keepalive" | keys | first | default "disabled" }} {{- $keepalive := groupByLabel $vpath_containers "com.github.nginx-proxy.nginx-proxy.keepalive" | keys | first | default "auto" }}
{{- $upstream := $vhost_data.upstream_name }} {{- $upstream := $vhost_data.upstream_name }}
{{- if (not (eq $path "/")) }} {{- if (not (eq $path "/")) }}

View File

@ -8,6 +8,8 @@ services:
environment: environment:
WEB_PORTS: 80 WEB_PORTS: 80
VIRTUAL_HOST: keepalive-disabled.nginx-proxy.test VIRTUAL_HOST: keepalive-disabled.nginx-proxy.test
labels:
com.github.nginx-proxy.nginx-proxy.keepalive: "disabled"
keepalive-enabled: keepalive-enabled:
image: web image: web
@ -29,8 +31,6 @@ services:
environment: environment:
WEB_PORTS: 80 WEB_PORTS: 80
VIRTUAL_HOST: keepalive-auto.nginx-proxy.test VIRTUAL_HOST: keepalive-auto.nginx-proxy.test
labels:
com.github.nginx-proxy.nginx-proxy.keepalive: "auto"
sut: sut:
image: nginxproxy/nginx-proxy:test image: nginxproxy/nginx-proxy:test