v2.2.0-rc.3.0.20200921194441-fe27f9cf0c7f h1:FNgOksW9dYrvJEh49E8p1FwFBJR2fTxDXJ60SUTC3dk=
Caddyfile
:8081 {
route {
@matcher1 path /path1
@matcher2 path /path2
redir @matcher1 https://example.com/?matcher1
redir @matcher2 https://example.com/?matcher2
}
}
$ ./caddy run -config ./Caddyfile
2020/09/22 20:33:07.747 INFO using provided configuration {"config_file": "./Caddyfile", "config_adapter": ""}
run: adapting config using caddyfile: parsing caddyfile tokens for 'route': ./Caddyfile:7 - Error during parsing: unrecognized directive: @matcher2
Caddyfile
:8081 {
route {
# two unused matchers
@matcher1 path /path1
@matcher2 path /path2
}
}
$ ./caddy run -config ./Caddyfile
2020/09/22 20:38:13.772 INFO using provided configuration {"config_file": "./Caddyfile", "config_adapter": ""}
panic: runtime error: slice bounds out of range [2:1]
goroutine 1 [running]:
github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile.parseSegmentAsConfig(0xc000855bf0, 0xc000855800, 0xc000855650, 0xc000a002c0, 0xc000855b90, 0xc000b55790, 0x1, 0x1, 0xc000a002a0, 0x1, ...)
github.com/caddyserver/caddy/[email protected]/caddyconfig/httpcaddyfile/directives.go:313 +0xd54
github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile.parseRoute(0xc000855bf0, 0xc000855800, 0xc000855650, 0xc000a002c0, 0xc000855b90, 0xc000b55790, 0x1, 0x1, 0xc000a002a0, 0x1, ...)
github.com/caddyserver/caddy/[email protected]/caddyconfig/httpcaddyfile/builtins.go:520 +0x78
github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile.RegisterHandlerDirective.func1(0xc000855bf0, 0xc000855800, 0xc000855650, 0xc000a002c0, 0xc000855b90, 0xc000b55790, 0x1, 0x1, 0xc000a002a0, 0x1, ...)
github.com/caddyserver/caddy/[email protected]/caddyconfig/httpcaddyfile/directives.go:119 +0x202
github.com/caddyserver/caddy/v2/caddyconfig/httpcaddyfile.ServerType.Setup(0xc0008557a0, 0x1, 0x1, 0xc000855650, 0xc000a002a0, 0x1, 0x1, 0x0, 0x0, 0x0)
github.com/caddyserver/caddy/[email protected]/caddyconfig/httpcaddyfile/httptype.go:171 +0x25e7
github.com/caddyserver/caddy/v2/caddyconfig/caddyfile.Adapter.Adapt(0x2893c00, 0x39991b0, 0xc0000b0000, 0x57, 0x257, 0xc000855650, 0xc000151200, 0xbe00000002370760, 0xc000abf670, 0xbe81c04da53083c2, ...)
github.com/caddyserver/caddy/[email protected]/caddyconfig/caddyfile/adapter.go:49 +0x13f
github.com/caddyserver/caddy/v2/cmd.loadConfig(0x7fff58cc0ec6, 0xb, 0x0, 0x0, 0xc0000ac8e0, 0xc000abfa58, 0x41699b, 0x7fd1cfb81700, 0x400, 0x7fd1cfd44fff, ...)
github.com/caddyserver/caddy/[email protected]/cmd/main.go:173 +0x2a4
github.com/caddyserver/caddy/v2/cmd.cmdRun(0xc0000a66c0, 0x0, 0x0, 0x0)
github.com/caddyserver/caddy/[email protected]/cmd/commandfuncs.go:205 +0x805
github.com/caddyserver/caddy/v2/cmd.Main()
github.com/caddyserver/caddy/[email protected]/cmd/main.go:85 +0x248
main.main()
caddy/main.go:19 +0x25
Thanks, I can replicate. Looking into it now.
Edit: Ah, that's easy - i+1 issue happens (length-overrun) when a matcher is the last thing in a route. Working on a fix.
@EHfive If you have a chance, could you test the fix from #3746 before we release v2.2.0 tomorrow or Thursday? You can also get the build artifacts here: https://github.com/caddyserver/caddy/actions/runs/267639346
Sure, I already tested, the fix #3746 works! Both test cases I mentioned above passed without any errors.
Most helpful comment
Sure, I already tested, the fix #3746 works! Both test cases I mentioned above passed without any errors.