Ping url healthcheck

I’m running caddy on several instances behind a load balancer. The load balancer needs a health check url to know if caddy is down or is going down soon. It’ll then stop routing traffic to that instance.

I couldn’t find anything about health checks other than caddy checking proxied instances itself.

The -grace flag will keep caddy running until x seconds on shutdown. In that period I’d like to have an endpoint respond with something else than a 200 status code. I looked at the template actions and http.status but couldn’t find anything.

I thought maybe something like this was possible:

:80/ping {
  status CADDYSTATUS /
}

I’m running caddy v1.

Good question; I don’t think that’s possible in Caddy 1. Could you file an issue to request that feature for Caddy 2?

in v1 there’s this on shutdown function:
https://caddyserver.com/v1/docs/on

Do you think I could utilise that in anyway as a temporary solution?