So, before I go spinning up a dev environment to check for myself, I wanted to ask if anyone knows how the import directive handles paths?
I’m expecting it to handle them relative to the location of the imported file, i.e. if my Caddyfile at ./Caddyfile imported ./site1/Caddyfile then all paths in ./site1/Caddyfile would be parsed relative to site1/ instead of relative to ./.
If so, this makes the process of deploying crap to Caddy at least 200% easier for me .
Update: Nope, it treats directory paths as relative to the Caddyfile that Caddy is loading. IMO, this is a bug, or if not a bug then it’s user-hostile behaviour.
IIRC nginx handles it the same way. (As in all imports are relative to the master nginx.conf location.)
So, is is better to handle this the “smart” way, or the “principle of least surprise” way?
I think the current/nginx way is sensible if you have a config somewhere in /etc that’s unrelated to the content and forms a complete config tree.
Relative imports make sense when your config comes together with the site (kinda like .htaccess).