I recently installed Caddy on one of my edge servers that previously worked as a reverse proxy for multiple websites using nginx. I managed to convert all the nginx templates (one for each site) in Caddyfile format (one .caddy file for each website) and imported all these files with a single centrale Caddyfile with a simple import directive (import *.caddy).
Problem is, any time I change one of the configuration files, I need to perform a /reload of the Caddy configuration, so it takes some time in order to adapt all configs to JSON format and load them. This takes relatively high amount of time and CPU usage.
Is there any way to instruct Caddy to just load one Caddyfile, then “append” another Caddyfile to the existing configuration and so on… so that whenever I need to modify a server (i.e., only ONE of the many Caddyfiles) I can just replace that specific config instead of all of them every time?
The real issue here is that I need to use Caddyfiles and can’t switch to JSON. At least not directly.
From the docs it seems that @id directive is missing for Caddyfile… Also, in my case one Caddyfile contains multiple snippets, server blocks and custom SSL certificates. I need some way to identify the full file with all blocks and snippets.
What I was thinking was to write a code that asks Caddy to adapt each Caddyfile to JSON format and put an @id for the whole JSON string. I don’t know if this is possible tho, from documentation it seems lile you can assign an ID only to some blocks, but I need one ID for one Caddyfile / JSON, is it feasible?