The issue description
The doImport function in parse.go seems unable to correctly parse the token, which will ultimately lead to an error in parsing the "Variadic placeholder".
The running environment
- Caddy:
v2.7.3 h1:eMCNjOyMgB5A1KgOzT2dXKR4I0Va+YHCJYC8HHu+DP0=
- OS:
Ubuntu Server 22.04
The configuration to reproduce the issue
(PKG_PROXY) {
reverse_proxy {args[0]}://{args[1]} {
header_up Host {args[1]}
}
}
:80 {
import PKG_PROXY https www.google.com
}
The error log
Variadic placeholder {args[0]}://{args[1]} has an invalid start index
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5864484,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"warn","ts":1691469998.5865088,"logger":"caddyfile","msg":"Variadic placeholder {args[0]}://{args[1]} has an invalid start index","file":"/etc/caddy/Caddyfile:2","import_chain":["/etc/caddy/Caddyfile:8 (import PKG_PROXY)"]}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"warn","ts":1691469998.5871835,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":2}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5877721,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"warn","ts":1691469998.587835,"logger":"http.auto_https","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5879872,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0x4000248b80"}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5880983,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5881765,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5881784,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5882018,"msg":"serving initial configuration"}
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5882034,"logger":"tls","msg":"finished cleaning storage units"}
The issue description
The
doImportfunction in parse.go seems unable to correctly parse the token, which will ultimately lead to an error in parsing the "Variadic placeholder".The running environment
v2.7.3 h1:eMCNjOyMgB5A1KgOzT2dXKR4I0Va+YHCJYC8HHu+DP0=Ubuntu Server 22.04The configuration to reproduce the issue
(PKG_PROXY) { reverse_proxy {args[0]}://{args[1]} { header_up Host {args[1]} } } :80 { import PKG_PROXY https www.google.com }The error log
Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5864484,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":""} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"warn","ts":1691469998.5865088,"logger":"caddyfile","msg":"Variadic placeholder {args[0]}://{args[1]} has an invalid start index","file":"/etc/caddy/Caddyfile:2","import_chain":["/etc/caddy/Caddyfile:8 (import PKG_PROXY)"]} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"warn","ts":1691469998.5871835,"msg":"Caddyfile input is not formatted; run 'caddy fmt --overwrite' to fix inconsistencies","adapter":"caddyfile","file":"/etc/caddy/Caddyfile","line":2} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5877721,"logger":"admin","msg":"admin endpoint started","address":"localhost:2019","enforce_origin":false,"origins":["//localhost:2019","//[::1]:2019","//127.0.0.1:2019"]} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"warn","ts":1691469998.587835,"logger":"http.auto_https","msg":"server is listening only on the HTTP port, so no automatic HTTPS will be applied to this server","server_name":"srv0","http_port":80} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5879872,"logger":"tls.cache.maintenance","msg":"started background certificate maintenance","cache":"0x4000248b80"} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5880983,"logger":"http.log","msg":"server running","name":"srv0","protocols":["h1","h2","h3"]} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5881765,"msg":"autosaved config (load with --resume flag)","file":"/var/lib/caddy/.config/caddy/autosave.json"} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5881784,"logger":"tls","msg":"cleaning storage unit","description":"FileStorage:/var/lib/caddy/.local/share/caddy"} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5882018,"msg":"serving initial configuration"} Aug 08 12:46:38 arm64 caddy[1309]: {"level":"info","ts":1691469998.5882034,"logger":"tls","msg":"finished cleaning storage units"}