1. The problem I’m having:
I have a VPS running services with docker. I use Caddy as a reverse proxy (not running in Docker).
My domain is configured on Cloudflare to point to my server IP. When a request hits my website, it is reverse proxied to my docker service on port 5000. Now, I ran docker compose down
to switch off the service and to trigger a 5xx error to test if my maintenance page is working.
However, I get the Cloudflare 502 Bad Gateway page in my browser rather than the custom page from the handle_error
Caddy directive.
2. Error messages and/or full log output:
3. Caddy version:
v2.8.4
4. How I installed and ran Caddy:
Installed Caddy via Ansible / apt-get install.
Running it with sudo systemctl start caddy
a. System environment:
Ubuntu 24 Server
b. Command:
sudo systemctl reload caddy
c. Service/unit/compose file:
d. My complete Caddy config:
site1.com, www.site1.com {
reverse_proxy 127.0.0.1:5000
reverse_proxy /api/_content 127.0.0.1:5000/api/_content
reverse_proxy /api/* 127.0.0.1:9000/api
handle_errors 5xx {
rewrite * /home/dv/site1.com/maintenance.html
file_server
}
}