1. Caddy version (caddy version
): 2.4.0 h1
2. How I run Caddy:
I run caddy via systemctl
a. System environment:
Ubuntu 20.04 LTS
b. Command:
sudo systemctl restart caddy
c. Service/unit/compose file:
[Unit]
Description=Caddy
Documentation=https://caddyserver.com/docs/
After=network.target
[Service]
User=caddy
Group=caddy
ExecStart=/usr/bin/caddy run --environ --config /etc/caddy/Caddyfile
ExecReload=/usr/bin/caddy reload --config /etc/caddy/Caddyfile
TimeoutStopSec=5s
LimitNOFILE=1048576
LimitNPROC=512
PrivateTmp=true
ProtectSystem=full
AmbientCapabilities=CAP_NET_BIND_SERVICE
EnvironmentFile=/etc/environment
[Install]
WantedBy=multi-user.target
d. My complete Caddyfile or JSON config:
{
on_demand_tls {
ask http://api.4ice.se/api/caddy-check
}
storage dynamodb caddy_ssl_certificates
}
:80 {
respond /health "Im healthy!" 200
}
:443 {
tls 4ice@gmail.com {
on_demand
}
reverse_proxy 4ice.se {
header_up X-Forwarded-Port {server_port}
health_timeout 5s
}
}
3. The problem I’m having:
I am using on_demand_tls for generating certificates for my multi tenant application. So for instance if someone creates a tenant with the domain caddy.4ice.se
, the ask
will get a 200 code, and the certificate will be created and the reverse proxy will send the request to the server.
The feature that I am looking for, is to be able to redirect the user if the ask
for the on_demand_tls fails. So for instance, if the user goes to not-setup-domain.4ice.se
and the ask
method gets a 503 error code as response, I want to make a 302 redirect for the user to the page 4ice.se/support
. Is that possible to do?