Closed marten-seemann closed 2 weeks ago
You can do this though:
{
// some global options
import sites-enabled/*_globals.Caddyfile
}
import sites-enabled/*_sites.Caddyfile
Thing is, import is literally just doing copy paste from one file into the main Caddyfile. It's not any smarter than that. We'd have to pretty significantly complicate the parser.
It works! Thank you for the quick response, @francislavoie!
Setup
I'm trying to run with a modular config. I have a very short
Caddyfile
that imports the site-specific configurations from included Caddyfiles.This allows me to easily move sites from one server instance to the other, by (basically) just moving the site-specific Caddyfile from one server to the other.
Some of the sites use the Git plugin to automatically fetch and update the code for the sites. The Git plugin requires repos to be configured globally, it's not possible (or at least I haven't figured out how) to have a git config in a site block.
Naturally, to keep the setup modular, the git configuration should be defined in the site-specific Caddyfiles, not in the top-level one.
The Problem
Caddy really, really doesn't like any global configuration that's not first:
This even applies if there's only one imported file, and the global option is the first directive in the imported file. This means it's not even possible to build the following structure:
Possible Solutions
I'm not very familiar with the intricacies of the design of the Caddyfile, so please let me know if I'm missing something here. I can see two solutions:
git
config directive needs to be global.