Caddy won't error in incorrect reverse proxy config block

Greetings,

I recently had an issue where caddy would start fine, but most of my services were blocked. By debugging I found that I was missing a single curly brace (which I thought caddy should have detected) to end a reverse proxy block. My config follows the flow below, though it is much larger.

*.domain.com {
    tls {
        dns cloudflare REDACTED
    }

    @test host test.domain.com
    handle @test {
            reverse_proxy 192.168.50.201:9200 {
                    header_up Host {hostport}
                    transport http { 
                        tls_insecure_skip_verify
                    }
    }
}

This block will not show an error when starting caddy. Can you spot the missing curly brace to end the reverse_proxy directive?

Any @ domains in front of the domain block in question still functioned, But and domain blocks after it would only show a white page.

By adding the closing curly brace everything started to work.

Reloading caddy worked.

Starting caddy worked.

Stoping caddy did not work, it just hung which was my first clue.

Is this a bug in caddy? Version=2.11.4

Not a bug, and it’s not that caddy misses forgotten braces. A truly unclosed block errors out with unclosed block (missing '}'). Since you got no error, your file was still brace balanced, just misnested: a } meant to close reverse_proxy closed an outer block instead, so the site blocks below got pulled inside *.domain.com instead of standing on their own.

Valid syntax, wrong routing. The swallowed domains fall under the wildcard with no matching route result to white page. The blocks above were already closed, so they kept working. Adding the brace back put the nesting right.

Run caddy fmt --overwrite and it jumps out, it re-indents by real brace depth, so a misnest makes everything below drift sideways.

(The stop hang is probably unrelated. It waits for connections to drain, and a keep-alive to :9200 can make it sit there.)

Ahhhh I see now. Thanks for that.