diff --git a/lib/kamal/configuration/docs/proxy.yml b/lib/kamal/configuration/docs/proxy.yml index f61ea229..dbf47a2b 100644 --- a/lib/kamal/configuration/docs/proxy.yml +++ b/lib/kamal/configuration/docs/proxy.yml @@ -77,7 +77,17 @@ proxy: path: /health timeout: 3 - # Max Request Body Size + # Buffering # - # The maximum request size in bytes that the proxy will accept, defaults to 1GB - max_request_body_size: 40_000_000 + # Whether to buffer request and response bodies in the proxy + # + # By default buffering is enabled with a max request body size of 1GB and no limit + # for response size. + # + # You can also set the memory limit for buffering, which defaults to 1MB, anything + # larger than that is written to disk. + buffering: + enabled: true + max_request_body: 40_000_000 + max_response_body: 0 + memory: 2_000_000 diff --git a/lib/kamal/configuration/proxy.rb b/lib/kamal/configuration/proxy.rb index 5dc3546b..732195d3 100644 --- a/lib/kamal/configuration/proxy.rb +++ b/lib/kamal/configuration/proxy.rb @@ -44,7 +44,11 @@ class Kamal::Configuration::Proxy "health-check-interval": proxy_config.dig("health_check", "interval"), "health-check-timeout": proxy_config.dig("health_check", "timeout"), "health-check-path": proxy_config.dig("health_check", "path"), - "target-timeout": proxy_config["response_timeout"] + "target-timeout": proxy_config["response_timeout"], + "buffer": proxy_config.fetch("buffer", { enabled: true }).fetch("enabled", true), + "buffer-memory": proxy_config.dig("buffer", "memory"), + "max-request-body": proxy_config.dig("buffer", "max_request_body"), + "max-response-body": proxy_config.dig("buffer", "max_response_body") }.compact end