From da8853d50290d3d7ab969512b038bb7b6ecbdcc0 Mon Sep 17 00:00:00 2001 From: Adrian Richter Date: Thu, 31 Aug 2023 13:56:08 +0200 Subject: [PATCH 1/2] Set caddys request_body directive (default 250MB) --- Dockerfile | 2 +- Dockerfile.dev | 2 +- caddy_base.json | 6 +++++- entrypoint | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 461a141..a6a4990 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM caddy:2.3.0-alpine +FROM caddy:2.7-alpine LABEL org.opencontainers.image.title="OpenSlides Proxy" LABEL org.opencontainers.image.description="The proxy is the entrypoint for traffic going into an OpenSlides instance." diff --git a/Dockerfile.dev b/Dockerfile.dev index c9ec9d7..85f0915 100644 --- a/Dockerfile.dev +++ b/Dockerfile.dev @@ -1,4 +1,4 @@ -FROM caddy:2.3.0-alpine +FROM caddy:2.7-alpine RUN apk update && apk add --no-cache jq gettext diff --git a/caddy_base.json b/caddy_base.json index 4940bda..206eb42 100644 --- a/caddy_base.json +++ b/caddy_base.json @@ -22,7 +22,7 @@ "servers": { "srv0": { "listen": [":8000"], - "allow_h2c": true, + "protocols": ["h1","h2"], "routes": [ { "handle": [ @@ -61,6 +61,10 @@ }, { "handle": [ + { + "handler": "request_body", + "max_size": $REQUEST_BODY_MAX_SIZE + }, { "handler": "reverse_proxy", "upstreams": [ diff --git a/entrypoint b/entrypoint index 1fc62cb..0502349 100755 --- a/entrypoint +++ b/entrypoint @@ -19,6 +19,7 @@ MEDIA_HOST="${MEDIA_HOST:-media}" MEDIA_PORT="${MEDIA_PORT:-9006}" \ MANAGE_HOST="${MANAGE_HOST:-manage}" MANAGE_PORT="${MANAGE_PORT:-9008}" \ CLIENT_HOST="${CLIENT_HOST:-client}" CLIENT_PORT="${CLIENT_PORT:-9001}" \ VOTE_HOST="${VOTE_HOST:-vote}" VOTE_PORT="${VOTE_PORT:-9013}" \ +REQUEST_BODY_MAX_SIZE="${REQUEST_BODY_MAX_SIZE:-250MB}" \ envsubst < "$config" > "$config.out" && mv -f "$config.out" "$config" jq_write() { From 8859538fe43f62f4a118bf11c1dcd5352d07485a Mon Sep 17 00:00:00 2001 From: Adrian Richter Date: Thu, 31 Aug 2023 16:41:03 +0200 Subject: [PATCH 2/2] Add a header to the response conveying the limit --- caddy_base.json | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/caddy_base.json b/caddy_base.json index 206eb42..a6315f4 100644 --- a/caddy_base.json +++ b/caddy_base.json @@ -61,6 +61,14 @@ }, { "handle": [ + { + "handler": "headers", + "response": { + "add": { + "Request-Body-Max-Size": ["$REQUEST_BODY_MAX_SIZE"] + } + } + }, { "handler": "request_body", "max_size": $REQUEST_BODY_MAX_SIZE