File tree Expand file tree Collapse file tree 6 files changed +77
-0
lines changed
Expand file tree Collapse file tree 6 files changed +77
-0
lines changed Original file line number Diff line number Diff line change @@ -499,6 +499,28 @@ ENV NGINX_WORKER_PROCESSES auto
499499COPY ./app /app
500500```
501501
502+ ## Custom Nginx maximum connections per worker
503+
504+ By default, Nginx will start with a maximum limit of 1024 connections per worker.
505+
506+ If you want to set a different number you can use the environment variable ` NGINX_WORKER_CONNECTIONS ` , e.g:
507+
508+ ``` Dockerfile
509+ ENV NGINX_WORKER_CONNECTIONS 2048
510+ ```
511+
512+ It cannot exceed the current limit on the maximum number of open files. See how to configure it in the next section.
513+
514+ ## Custom Nginx maximum open files
515+
516+ The number connections per Nginx worker cannot exceed the limit on the maximum number of open files.
517+
518+ You can change the limit of open files with the environment variable ` NGINX_WORKER_OPEN_FILES ` , e.g.:
519+
520+ ``` Dockerfile
521+ ENV NGINX_WORKER_OPEN_FILES 2048
522+ ```
523+
502524## Customizing Nginx configurations
503525
504526If you need to configure Nginx further, you can add ` *.conf ` files to ` /etc/nginx/conf.d/ ` in your Dockerfile.
Original file line number Diff line number Diff line change @@ -10,6 +10,17 @@ USE_NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1}
1010# Modify the number of worker processes in Nginx config
1111sed -i " /worker_processes\s/c\worker_processes ${USE_NGINX_WORKER_PROCESSES} ;" /etc/nginx/nginx.conf
1212
13+ # Set the max number of connections per worker for Nginx, if requested
14+ # Cannot exceed worker_rlimit_nofile, see NGINX_WORKER_OPEN_FILES below
15+ if [[ -v NGINX_WORKER_CONNECTIONS ]] ; then
16+ sed -i " /worker_connections\s/c\ worker_connections ${NGINX_WORKER_CONNECTIONS} ;" /etc/nginx/nginx.conf
17+ fi
18+
19+ # Set the max number of open file descriptors for Nginx workers, if requested
20+ if [[ -v NGINX_WORKER_OPEN_FILES ]] ; then
21+ echo " worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES} ;" >> /etc/nginx/nginx.conf
22+ fi
23+
1324# Get the URL for static files from the environment variable
1425USE_STATIC_URL=${STATIC_URL:- ' /static' }
1526# Get the absolute path of the static files from the environment variable
Original file line number Diff line number Diff line change @@ -10,6 +10,17 @@ USE_NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1}
1010# Modify the number of worker processes in Nginx config
1111sed -i " /worker_processes\s/c\worker_processes ${USE_NGINX_WORKER_PROCESSES} ;" /etc/nginx/nginx.conf
1212
13+ # Set the max number of connections per worker for Nginx, if requested
14+ # Cannot exceed worker_rlimit_nofile, see NGINX_WORKER_OPEN_FILES below
15+ if [[ -v NGINX_WORKER_CONNECTIONS ]] ; then
16+ sed -i " /worker_connections\s/c\ worker_connections ${NGINX_WORKER_CONNECTIONS} ;" /etc/nginx/nginx.conf
17+ fi
18+
19+ # Set the max number of open file descriptors for Nginx workers, if requested
20+ if [[ -v NGINX_WORKER_OPEN_FILES ]] ; then
21+ echo " worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES} ;" >> /etc/nginx/nginx.conf
22+ fi
23+
1324# Get the URL for static files from the environment variable
1425USE_STATIC_URL=${STATIC_URL:- ' /static' }
1526# Get the absolute path of the static files from the environment variable
Original file line number Diff line number Diff line change @@ -10,6 +10,17 @@ USE_NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1}
1010# Modify the number of worker processes in Nginx config
1111sed -i " /worker_processes\s/c\worker_processes ${USE_NGINX_WORKER_PROCESSES} ;" /etc/nginx/nginx.conf
1212
13+ # Set the max number of connections per worker for Nginx, if requested
14+ # Cannot exceed worker_rlimit_nofile, see NGINX_WORKER_OPEN_FILES below
15+ if [[ -v NGINX_WORKER_CONNECTIONS ]] ; then
16+ sed -i " /worker_connections\s/c\ worker_connections ${NGINX_WORKER_CONNECTIONS} ;" /etc/nginx/nginx.conf
17+ fi
18+
19+ # Set the max number of open file descriptors for Nginx workers, if requested
20+ if [[ -v NGINX_WORKER_OPEN_FILES ]] ; then
21+ echo " worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES} ;" >> /etc/nginx/nginx.conf
22+ fi
23+
1324# Get the URL for static files from the environment variable
1425USE_STATIC_URL=${STATIC_URL:- ' /static' }
1526# Get the absolute path of the static files from the environment variable
Original file line number Diff line number Diff line change @@ -10,6 +10,17 @@ USE_NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1}
1010# Modify the number of worker processes in Nginx config
1111sed -i " /worker_processes\s/c\worker_processes ${USE_NGINX_WORKER_PROCESSES} ;" /etc/nginx/nginx.conf
1212
13+ # Set the max number of connections per worker for Nginx, if requested
14+ # Cannot exceed worker_rlimit_nofile, see NGINX_WORKER_OPEN_FILES below
15+ if [[ -v NGINX_WORKER_CONNECTIONS ]] ; then
16+ sed -i " /worker_connections\s/c\ worker_connections ${NGINX_WORKER_CONNECTIONS} ;" /etc/nginx/nginx.conf
17+ fi
18+
19+ # Set the max number of open file descriptors for Nginx workers, if requested
20+ if [[ -v NGINX_WORKER_OPEN_FILES ]] ; then
21+ echo " worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES} ;" >> /etc/nginx/nginx.conf
22+ fi
23+
1324# Get the URL for static files from the environment variable
1425USE_STATIC_URL=${STATIC_URL:- ' /static' }
1526# Get the absolute path of the static files from the environment variable
Original file line number Diff line number Diff line change @@ -10,6 +10,17 @@ USE_NGINX_WORKER_PROCESSES=${NGINX_WORKER_PROCESSES:-1}
1010# Modify the number of worker processes in Nginx config
1111sed -i " /worker_processes\s/c\worker_processes ${USE_NGINX_WORKER_PROCESSES} ;" /etc/nginx/nginx.conf
1212
13+ # Set the max number of connections per worker for Nginx, if requested
14+ # Cannot exceed worker_rlimit_nofile, see NGINX_WORKER_OPEN_FILES below
15+ if [[ -v NGINX_WORKER_CONNECTIONS ]] ; then
16+ sed -i " /worker_connections\s/c\ worker_connections ${NGINX_WORKER_CONNECTIONS} ;" /etc/nginx/nginx.conf
17+ fi
18+
19+ # Set the max number of open file descriptors for Nginx workers, if requested
20+ if [[ -v NGINX_WORKER_OPEN_FILES ]] ; then
21+ echo " worker_rlimit_nofile ${NGINX_WORKER_OPEN_FILES} ;" >> /etc/nginx/nginx.conf
22+ fi
23+
1324# Get the URL for static files from the environment variable
1425USE_STATIC_URL=${STATIC_URL:- ' /static' }
1526# Get the absolute path of the static files from the environment variable
You can’t perform that action at this time.
0 commit comments