Is this Caddyfile syntax invalid, or is it a bug?

1. Caddy version (caddy version):


2. How I run Caddy:

a. System environment:

Debian Bullseye

b. Command:

systemctl start caddy

c. Service/unit/compose file:


ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile


d. My complete Caddyfile or JSON config:

(nested) {
	header server pseudo

(problem) {
	import nested
	reverse_proxy {args.0}

(serve) {
	handle {
		import problem {args.0}
} {
	import serve

3. The problem I’m having:

The above Caddyfile only validates when the “import nested” line is commented out, or when the handle block is stripped from (serve). I would like to find out if this is by design, or due to a bug that affects nesting.

4. Error messages and/or full log output:

validate: adapting config using caddyfile: parsing caddyfile tokens for ‘handle’: Caddyfile:13 - Error during parsing: unrecognized directive: import - are you sure your Caddyfile structure (nesting and braces) is correct?

5. What I already tried:

I have reduced a very complex Caddyfile to the crux of the issue.

6. Links to relevant resources:

Huh, interesting. I’d probably call it a bug. But I’m not sure why that happens. The import should already be expanded before handle gets to see it. I’ll need to investigate further.

Feel free to open an issue on github for this :+1:

1 Like

Thanks, I’ll do just that.

This topic was automatically closed after 30 days. New replies are no longer allowed.