When I add the additional notfound matcher and the handle_response directive, Caddy fails to start up.
4. Error messages and/or full log output:
May 14 09:45:27 caddy[549]: {"level":"info","ts":1620978327.6110585,"msg":"using provided configuration","config_file":"/etc/caddy/Caddyfile","config_adapter":"caddyfile"}
May 14 09:45:27 caddy[549]: run: adapting config using caddyfile: getting matcher module 'status': module not registered: http.matchers.status
Is the status matcher not part of the official builds? In case it requires a custom build, how would this work and should this be mentioned in the reverse_proxy documenation?
In your current Caddyfile, this section is outside the reverse_proxy directive block:
The status matcher and the handle_response directive are part of the reverse_proxy namespace. Currently you have the reverse_proxy at the top of your Caddyfile, then handle_response at the bottom of the Caddyfile containing outside of the reverse_proxy directive. Put the matcher and the handle_response inside the the reverse_proxy directive at the top.
Thanks for the pointer @Mohammed90 - this makes sense.
I don’t know what I am doing wrong, but I get another error after changing the config like this:
May 14 11:54:28 caddy[549]: run: adapting config using caddyfile: parsing caddyfile tokens for 'reverse_proxy': /etc/caddy/Caddyfile:88 - Error during parsing: parsing caddyfile tokens for 'rewrite': /etc/caddy/Caddyfile:86 - Error during parsing: Wrong argument count or unexpected line ending after 'rewrite'
It’s an idiosyncrasy of the parser. See because the argument starts with a forward slash /, the parser assumes it’s a matcher, which leads it to believe the second argument is missing. In such cases, it’s best being explicit by including the wildcard matcher *.