From 8f7b234a125627a437ad102a7078aeea690d5eb4 Mon Sep 17 00:00:00 2001 From: Bernhard Sirlinger Date: Mon, 26 Dec 2022 22:42:22 +0100 Subject: [PATCH] feat: make client_max_body_size configurable via env (#1029) --- compose.yaml | 1 + example.env | 4 ++++ images/nginx/Dockerfile | 1 + images/nginx/nginx-template.conf | 2 +- pwd.yml | 1 + 5 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compose.yaml b/compose.yaml index 6c5329ac..c27a9072 100644 --- a/compose.yaml +++ b/compose.yaml @@ -36,6 +36,7 @@ services: UPSTREAM_REAL_IP_HEADER: ${UPSTREAM_REAL_IP_HEADER:-X-Forwarded-For} UPSTREAM_REAL_IP_RECURSIVE: ${UPSTREAM_REAL_IP_RECURSIVE:-off} PROXY_READ_TIMOUT: ${PROXY_READ_TIMOUT:-120} + CLIENT_MAX_BODY_SIZE: ${CLIENT_MAX_BODY_SIZE:-50m} volumes: - sites:/usr/share/nginx/html/sites - assets:/usr/share/nginx/html/assets diff --git a/example.env b/example.env index 2eb64c12..e6f582be 100644 --- a/example.env +++ b/example.env @@ -42,3 +42,7 @@ UPSTREAM_REAL_IP_RECURSIVE= # All Values Allowed by nginx proxy_read_timeout are allowed, default value is 120s # Useful if you have longrunning print formats or slow loading sites PROXY_READ_TIMOUT= + +# All Values allowed by nginx client_max_body_size are allowed, default value is 50m +# Necessary if the upload limit in the frappe application is increased +CLIENT_MAX_BODY_SIZE= diff --git a/images/nginx/Dockerfile b/images/nginx/Dockerfile index 63cc4d9d..29d92b79 100644 --- a/images/nginx/Dockerfile +++ b/images/nginx/Dockerfile @@ -44,6 +44,7 @@ FROM nginxinc/nginx-unprivileged:1.23.3-alpine as frappe # Set default ENV variables for backwards compatibility ENV PROXY_READ_TIMOUT=120 +ENV CLIENT_MAX_BODY_SIZE=50m # https://github.com/nginxinc/docker-nginx-unprivileged/blob/main/stable/alpine/20-envsubst-on-templates.sh COPY nginx-template.conf /etc/nginx/templates/default.conf.template diff --git a/images/nginx/nginx-template.conf b/images/nginx/nginx-template.conf index 36e64e56..90eabeea 100644 --- a/images/nginx/nginx-template.conf +++ b/images/nginx/nginx-template.conf @@ -87,7 +87,7 @@ server { # optimizations sendfile on; keepalive_timeout 15; - client_max_body_size 50m; + client_max_body_size ${CLIENT_MAX_BODY_SIZE}; client_body_buffer_size 16K; client_header_buffer_size 1k; diff --git a/pwd.yml b/pwd.yml index ce39763a..a538ae4e 100644 --- a/pwd.yml +++ b/pwd.yml @@ -88,6 +88,7 @@ services: UPSTREAM_REAL_IP_HEADER: X-Forwarded-For UPSTREAM_REAL_IP_RECURSIVE: "off" PROXY_READ_TIMOUT: 120 + CLIENT_MAX_BODY_SIZE: 50m volumes: - sites:/usr/share/nginx/html/sites - assets:/usr/share/nginx/html/assets