From d9ba107da2d3722de3134e67e2d7f9f05b47c175 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 29 Jan 2025 10:45:50 +0100 Subject: [PATCH 1/3] :wrench: Update default body size for docker images Set it to 350MiB, the same as we have on our saas --- docker/images/files/nginx.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/images/files/nginx.conf b/docker/images/files/nginx.conf index e03f7ef0b..ee732a945 100644 --- a/docker/images/files/nginx.conf +++ b/docker/images/files/nginx.conf @@ -64,7 +64,7 @@ http { listen 8080 default_server; server_name _; - client_max_body_size 100M; + client_max_body_size 350M; charset utf-8; proxy_http_version 1.1; From f252ffb201f1be7e95f74616a1105a0a94393618 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 29 Jan 2025 12:22:05 +0100 Subject: [PATCH 2/3] :sparkles: Add the ability to overwrite default http body size on docker images And provide a compose file with good defaults --- docker/images/docker-compose.yaml | 15 +++++++++++---- docker/images/files/nginx-entrypoint.sh | 4 +++- docker/images/files/nginx.conf | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/docker/images/docker-compose.yaml b/docker/images/docker-compose.yaml index c745f78be..ee06c0933 100644 --- a/docker/images/docker-compose.yaml +++ b/docker/images/docker-compose.yaml @@ -29,6 +29,15 @@ x-flags: &penpot-flags x-uri: &penpot-public-uri PENPOT_PUBLIC_URI: http://localhost:9001 +x-body-size: &penpot-http-body-size + # Max body size (30MiB); Used for plain requests, should never be + # greater than multi-part size + PENPOT_HTTP_SERVER_MAX_BODY_SIZE: 31457280 + + # Max multipart body size (350MiB) + PENPOT_HTTP_SERVER_MAX_MULTIPART_BODY_SIZE: 367001600 + + networks: penpot: @@ -103,7 +112,7 @@ services: # - "traefik.http.routers.penpot-https.tls.certresolver=letsencrypt" environment: - << : *penpot-flags + << : [*penpot-flags, *penpot-http-body-size] penpot-backend: image: "penpotapp/backend:latest" @@ -123,7 +132,7 @@ services: ## container. environment: - << : [*penpot-flags, *penpot-public-uri] + << : [*penpot-flags, *penpot-public-uri, *penpot-http-body-size] ## Penpot SECRET KEY. It serves as a master key from which other keys for subsystems ## (eg http sessions, or invitations) are derived. @@ -261,5 +270,3 @@ services: # ports: # - 9000:9000 # - 9001:9001 - - diff --git a/docker/images/files/nginx-entrypoint.sh b/docker/images/files/nginx-entrypoint.sh index c34245230..74c0042d6 100644 --- a/docker/images/files/nginx-entrypoint.sh +++ b/docker/images/files/nginx-entrypoint.sh @@ -22,7 +22,9 @@ update_flags /var/www/app/js/config.js export PENPOT_BACKEND_URI=${PENPOT_BACKEND_URI:-http://penpot-backend:6060}; export PENPOT_EXPORTER_URI=${PENPOT_EXPORTER_URI:-http://penpot-exporter:6061}; export PENPOT_INTERNAL_RESOLVER=${PENPOT_INTERNAL_RESOLVER:-127.0.0.11}; +export PENPOT_HTTP_SERVER_MAX_MULTIPART_BODY_SIZE=${PENPOT_HTTP_SERVER_MAX_MULTIPART_BODY_SIZE:-367001600}; # Default to 350MiB -envsubst "\$PENPOT_BACKEND_URI,\$PENPOT_EXPORTER_URI,\$PENPOT_INTERNAL_RESOLVER" < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf +envsubst "\$PENPOT_BACKEND_URI,\$PENPOT_EXPORTER_URI,\$PENPOT_INTERNAL_RESOLVER,\$PENPOT_HTTP_SERVER_MAX_MULTIPART_BODY_SIZE" \ + < /etc/nginx/nginx.conf.template > /etc/nginx/nginx.conf exec "$@"; diff --git a/docker/images/files/nginx.conf b/docker/images/files/nginx.conf index ee732a945..19f2e3a1a 100644 --- a/docker/images/files/nginx.conf +++ b/docker/images/files/nginx.conf @@ -64,7 +64,7 @@ http { listen 8080 default_server; server_name _; - client_max_body_size 350M; + client_max_body_size $PENPOT_HTTP_SERVER_MAX_MULTIPART_BODY_SIZE; charset utf-8; proxy_http_version 1.1; From 47f1ca9627899c2c89c626121f4dab0c1aaa3b94 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 29 Jan 2025 12:26:30 +0100 Subject: [PATCH 3/3] :sparkles: Change backend defaults for http body --- backend/src/app/http.clj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/app/http.clj b/backend/src/app/http.clj index 4d85cdaee..e04b0523d 100644 --- a/backend/src/app/http.clj +++ b/backend/src/app/http.clj @@ -42,8 +42,8 @@ (def default-params {::port 6060 ::host "0.0.0.0" - ::max-body-size (* 1024 1024 30) ; default 30 MiB - ::max-multipart-body-size (* 1024 1024 120)}) ; default 120 MiB + ::max-body-size 31457280 ; default 30 MiB + ::max-multipart-body-size 367001600}) ; default 350 MiB (defmethod ig/expand-key ::server [k v]