From 8032a36276e455420e0a9c6b648ab2ecc978eeac Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 16 Jun 2025 18:43:11 +0000 Subject: [PATCH 1/2] Adding WORKER_CONNECTIONS, defaulting to 1024 --- Dockerfile | 5 +++-- README.md | 5 +++-- src/etc/nginx/nginx.conf.template | 4 ++++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 82c724a..c3e9f31 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ ############ -# Base +# Base ############ FROM alpine:3 AS base RUN apk add --no-cache \ @@ -15,6 +15,7 @@ ENV HEALTHCHECK_PATH="/lb-status/" ENV STATIC_LOCATIONS= ENV NO_ACCESS_LOGS=0 ENV LOG_ONLY_5XX=0 +ENV WORKER_CONNECTIONS=1024 EXPOSE 80 STOPSIGNAL SIGQUIT ENTRYPOINT ["/docker-entrypoint.sh"] @@ -35,7 +36,7 @@ WORKDIR /test_uwsgi RUN /test_uwsgi/test.sh ############ -# Final +# Final ############ FROM base LABEL "com.datadoghq.ad.check_names"='["nginx"]' diff --git a/README.md b/README.md index 5310e15..e8de132 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ environments such as AWS ECS. ## Features -- Structured logs with a lot more data than the standard nginx access format. +- Structured logs with a lot more data than the standard nginx access format. - [uWSGI][] support - Support for hosting static assets mounted from another container @@ -27,6 +27,7 @@ Pair nginx-proxy with your favorite upstream server (wsgi, uwsgi, asgi, et al.) | `HEALTHCHECK_PATH` | nginx-proxy disables healthcheck path access logs, you can configure the path here | Yes | /lb-status/ | | | `NO_ACCESS_LOGS` | disable access logs completely | No | 0 | 1 | | `LOG_ONLY_5XX` | only log 5XX HTTP status access events | No | 0 | 1 | +| `WORKER_CONNECTIONS` | Set the number of allowed worker connections | No | 1024 | 2048 | ### Hosting Static Assets @@ -79,7 +80,7 @@ Notable differences from the official [nginx container][] - [gomplate][] is used to render nginx configuration templates so that image startup is aborted if a template variable is missing. This is an improvement over the - official image, which uses `envsubst`. + official image, which uses `envsubst`. - alpine's official nginx package is used in order to ensure compatibility with distro-provided nginx modules. This is another enhancement, as the official image cannot be used with alpine's nginx modules. diff --git a/src/etc/nginx/nginx.conf.template b/src/etc/nginx/nginx.conf.template index 9848865..ffaebe0 100644 --- a/src/etc/nginx/nginx.conf.template +++ b/src/etc/nginx/nginx.conf.template @@ -8,7 +8,11 @@ pid /var/run/nginx.pid; load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so; events { + {{ if .Env.WORKER_CONNECTIONS }} + worker_connections {{ .Env.WORKER_CONNECTIONS }}; + {{ else }} worker_connections 1024; + {{ end }} use epoll; } From 571ea0ece2434d08ed97df89a967bf8a97644927 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Mon, 16 Jun 2025 20:02:11 +0000 Subject: [PATCH 2/2] Removed conditional from setting worker connections --- src/etc/nginx/nginx.conf.template | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/etc/nginx/nginx.conf.template b/src/etc/nginx/nginx.conf.template index ffaebe0..a7889b6 100644 --- a/src/etc/nginx/nginx.conf.template +++ b/src/etc/nginx/nginx.conf.template @@ -8,11 +8,7 @@ pid /var/run/nginx.pid; load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so; events { - {{ if .Env.WORKER_CONNECTIONS }} worker_connections {{ .Env.WORKER_CONNECTIONS }}; - {{ else }} - worker_connections 1024; - {{ end }} use epoll; }