Unfortunately it’s not possible to set idle timeouts from the Caddyfile because site blocks don’t map 1:1 to servers, but timeouts must be set on the servers. The Caddyfile does some magic to consolidate sites to servers as appropriate based on the listener addresses. It’s a tricky problem to solve without ambiguity.
I wrote up a proposal for this though, but it’s still under discussion:
opened 06:55AM - 20 Aug 20 UTC
closed 07:46PM - 23 Nov 20 UTC
feature
discussion
We have plenty of per-server options available in the JSON that don't yet have C… addyfile equivalents. See here: https://caddyserver.com/docs/json/apps/http/
After discussing with @whitestrake, I think we can group the ones that are missing into 3 new directives. Proposed syntax below:
```
timeouts {
read_body <duration>
read_header <duration>
write <duration>
idle <duration>
}
limits {
max_body_size <size>
max_header_size <size>
}
protocol {
allow_h2c
experimental_http3
strict_sni_host
}
```
Notice that `max_body_size` is not one of the server options in JSON. This would map to the [`request_body`](https://caddyserver.com/docs/modules/http.handlers.request_body) handler which is currently only available in JSON, with the concession that from the Caddyfile, no matchers could be used (i.e. matching all requests), and it would be added at the top of the routes.
Every option other than `max_body_size` would just be directly passed through to the JSON as-is.
Since `experimental_http3` is already a global option, the global option would of course take precedence in enabling it for all servers, and this new per-server option wouldn't offer an opt-out. Either on globally, or on per-server.
2 Likes