Overview
I've recently started using the Caddy Server as an easy way to fulfill some file and web hosting needs. Coming from Nginx, one of the annoyances I've come across is the standard layout of a single Caddyfile.
The import
directive exists and it can be used to
transform a single Caddyfile into an Nginx style "sites-enabled" layout.
Steps
To split the Caddyfile, create/move the specific site configuration in
individual configuration files. I give the files a .caddy
extension but it is
not required.
Once the configs are ready, import them in the main Caddyfile, start/reload Caddy and you are done. If a site needs to be disabled or a new site added, modify the main Caddyfile then reload Caddy.
An example Caddyfile using the import
directive is below:
import site1.caddy
import site2.caddy
More examples can also be found in Caddy's import documentation.