File upload size limits

Is there a way to set file upload size limit in Caddy 2.0.0? I used to do that with client_max_body_size in nginx but I can’t find it anywhere in the current Caddy docs.

Thank you, Karol

Yep, you want the request_body handler: Modules - Caddy Documentation

Thank you Matt, this is exactly what I’ve been looking for. The thing is I can’t find any article in the docs on how to use modules listed in Modules - Caddy Documentation. I tried to use request_body as a directive but Caddy rejects it. I’m using Caddyfile format and building Caddy with docker in case it matters (below). Could you point me to a doc on how to use this request_body module or modules in general? Thank you

FROM caddy:2.0.0-builder AS caddy-builder

RUN caddy-builder

FROM caddy:2.0.0

COPY --from=caddy-builder /usr/bin/caddy /usr/bin/caddy

It’s just {"handler": "request_body" ...} in one of your HTTP routes, as described here: JSON Config Structure - Caddy Documentation

This plugin may help if you’re new to it! (I actually use it quite often.) Getting a better experience with JSON/YAML configuration

Is it possible to use those from Caddyfile? I tried every combination possible from within reverse_proxy directive that I want to apply this to with no luck. Also tried to define a route directive and define it from within but still no luck. If this is json only I will switch but I really like the Caddyfile simplicity.

It hasn’t been integrated with the Caddyfile. Easy to do though, would definitely accept a pull request!

Thank you, I will try to come up with something in my spare time but I have no prior go experience.

This topic was automatically closed after 30 days. New replies are no longer allowed.