Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ 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"]
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ Pair nginx-proxy with your favorite upstream server (wsgi, uwsgi, asgi, et al.)
| `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 |
| `WORKER_FILE_LIMIT` | Set the number of available file descriptors | No | 2*WORKER_CONNECTIONS | 4096 |

### Hosting Static Assets

Expand Down Expand Up @@ -88,4 +89,4 @@ Notable differences from the official [nginx container][]
[nginx container]: https://hub.docker.com/_/nginx
[gomplate]: https://docs.gomplate.ca/
[uwsgi]: https://uwsgi-docs.readthedocs.io/en/latest/
[nginx status]: https://nginx.org/en/docs/http/ngx_http_stub_status_module.html
[nginx status]: https://nginx.org/en/docs/http/ngx_http_stub_status_module.html
3 changes: 3 additions & 0 deletions src/docker-entrypoint.d/00-render-templates.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ function render_templates {
done
}

export WORKER_FILE_LIMIT=${WORKER_FILE_LIMIT:=$(( WORKER_CONNECTIONS * 2 ))}
export WSGI_TIMEOUT=${WSGI_TIMEOUT:-${KEEPALIVE_TIMEOUT}}

render_templates "/etc/nginx/*.template" "/etc/nginx"
render_templates "/etc/nginx/conf.d/*.template" "/etc/nginx/conf.d"
render_templates "/etc/nginx/includes/*.template" "/etc/nginx/includes"
4 changes: 2 additions & 2 deletions src/etc/nginx/conf.d/default.conf.template
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Default configuration returns 400 in order to deny any request with an
# Default configuration returns 400 in order to deny any request with an
# unrecognized host header (server_name.)
{{ if (ne .Env.SERVER_NAME "_") }}
server {
Expand All @@ -21,7 +21,7 @@ server {
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";

location / {
{{ if (eq .Env.PROXY_UWSGI "1") }}
include /etc/nginx/includes/uwsgi.conf;
Expand Down
4 changes: 2 additions & 2 deletions src/etc/nginx/includes/uwsgi.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ uwsgi_pass app;
uwsgi_param HTTP_X_REQUEST_ID $request_id;
uwsgi_param HTTP_HOST $host;
include uwsgi_params;
uwsgi_read_timeout {{ .Env.KEEPALIVE_TIMEOUT }};
uwsgi_send_timeout {{ .Env.KEEPALIVE_TIMEOUT }};
uwsgi_read_timeout {{ .Env.WSGI_TIMEOUT }};
uwsgi_send_timeout {{ .Env.WSGI_TIMEOUT }};
1 change: 1 addition & 0 deletions src/etc/nginx/nginx.conf.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pid /var/run/nginx.pid;
# Used to zap Server header
load_module /usr/lib/nginx/modules/ngx_http_headers_more_filter_module.so;

worker_rlimit_nofile {{ .Env.WORKER_FILE_LIMIT }};
events {
worker_connections {{ .Env.WORKER_CONNECTIONS }};
use epoll;
Expand Down