I’m trying to set up my caddyfile
s in a more reusable way, so I had a look at the documentation and saw that the import
keyword is probably what I’m looking for.
Everything seemed to work fine until I introduced some proxy
blocks into the file.
I don’t know if it’s the proxy
blocks themselves that are causing the issue, or if this is just a problem with import
in general, but as soon as I did that I got this error:
2017/09/22 08:53:29 foo.caddyfile:3 - Error during parsing: Unexpected ‘}’ because no matching opening brace
My folder structure looks like this:
caddy
|__ 0.10.9
| |__ caddy.exe
| |__ ...
|
|__ conf
| |__ common.caddyfile
| |__ app.caddyfile
|
|__ sites
| |__ foo.caddyfile
|
|__ caddy.bat
|__ Caddyfile
caddy.bat
just contains a simple command to start the server:
%_caddy%\caddy.exe -conf l:\path\to\Caddyfile
Where %_caddy%
is just a variable set to the directory of whichever version of Caddy I’m using; in this case 0.10.9
.
Caddyfile
contains a line to import all files in sites
:
import "sites/*"
common.caddyfile
just has some directives in it that are common to all of my applications for local development:
tls self_signed
header / {
X-XSS-Protection "1; mode=block"
X-Content-Type-Options "nosniff"
X-Frame-Options "DENY"
}
app.caddyfile
contains some directives that are specific to that application:
import "common.caddyfile"
proxy / localhost:3001 {
transparent
}
And then finally, I just import the application specific caddy file for the domain I want in the foo.caddyfile
file:
https://local.foo.co.uk {
import "../conf/app.caddyfile"
}
Doing this produces the error pasted in at the beginning of this post.
If however I move the proxy
block out of app.caddyfile
and into foo.caddyfile
like this:
https://local.foo.co.uk {
import "../conf/app.caddyfile"
proxy / localhost:3001 {
transparent
}
}
Meaning the app.caddyfile
now only contains the line import "common.caddyfile"
, the server will then start up without any errors.
Is this just a bug in Caddy itself or am I doing something wrong?