Are there any plans to support includes in Caddyfile?
We store virtualhost configurations in separate files, so, it’d be great to do something like this in Caddyfile:
{
some general conifg
include /etc/caddy/additional_config.caddy
}
include /etc/caddy/snippets.caddy
include /etc/caddy/vhosts.caddy
Where /etc/caddy/vhosts.caddy
would have something like:
include /etc/caddy/vhosts/domain1.com.caddy
include /etc/caddy/vhosts/domain2.com.caddy
include /etc/caddy/vhosts/domain3.com.caddy
And, of course /etc/caddy/vhosts/domain1.com.caddy
would be the final vhost config, like:
example.com www.example.com {
.....
}
If it’s not planned (or supported already), we’ll be forced to use JSON API to add vhosts to caddy and load them all ons starting time. However, I haven’t found a way to use JSON API securely, or am I just missing this? I mean anyone having access to localhost (shared webhosting) could do actions with it. I’d suggest using control socket, like “nginx unit” does (Configuration — NGINX Unit). That way /path/to/control.caddy.sock
would be only accessible by root, and no one else would be able to do actions with the API.
Thank you!