1. The problem I’m having:
When I create a special file on disk I want to show a (maintenance) message instead of passing requests on to a reverse_proxy.
The provided config should work but I am wondering:
-
Could I deliver the content of the file “message.html” for (all requests) and still return a 503?
-
What is the performance impact of the file check? Will it check on disk for every request?
Or is there a better way of doing this?
2. Error messages and/or full log output:
NA
3. Caddy version:
$ caddy version
2.7.6
4. How I installed and ran Caddy:
NixOS via systemd
/nix/store/1cvy9h1k8lfc9na97g8fx6iy6sr5i3dz-caddy-2.7.6/bin/caddy run --config /etc/caddy/caddy_config --adapter caddyfile
a. System environment:
NixOS, arm
b. Command:
NA
c. Service/unit/compose file:
NA
d. My complete Caddy config:
{
log {
level ERROR
}
}
echo1.vafer.com {
log {
output file /var/log/caddy/access-echo1.vafer.com.log
}
# if file "message.html" exist on disk show it
root * /etc/caddy/message
@exists {
file message.html
}
handle @exists {
respond "We will be back shortly" 503 {
close
}
}
# otherwise pass on to proxy
handle {
reverse_proxy echo1.default.svc.cluster.local:80
}
tls internal
}