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
./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 .
Thanks in advance c:
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.
You may be right. Any other thoughts? Anyone want to implement this change?
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).
The Caddyfile typically lives near the site(s) it is configuring.
This is my goal, to have a Caddyfile in each site’s directory, and then have a “global” Caddyfile that
imports each site.
I’m not exactly sure, but I think this PR solved that problem.
@alfiepates Will you be able to pull the latest and confirm that it does what you expect?
./ in the imported Caddyfile still resolves to
./ relative to the importing Caddyfile.
@pedronasser Do you want to work on this? Since you just made a related fix recently?
I’ve sent a PR with a possible solution.
Not sure if it solves every case.
I’ll test a bit more.
EDIT: I’ve found a bug in discourse!
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.