Respond will make me an endpont to query, if Caddy are responding to http requests on port 10000, but it will not tell me the status of the reverse_proxy upstream hosts (host1 and host2). I am looking for a way to query Caddy for the current health status of the reverse_proxy hosts.
Ah, that’s not something that Caddy exposes currently; the proxy upstream pool is just maintained internally.
Best thing you can do probably is make a request to Caddy for /foo/health like your upstream seems to expose, and if there’s no available upstream, Caddy will serve you a 502, otherwise you’ll get a successful response. It’s as simple as that, really.
Oh right – but still, how can you tell if any given handler is “healthy”, in the sense that all the upstreams it has references to are healthy, if there can be upstreams that are for other handlers, in the pool?
Think of a situation where you have handler 1 which has upstreams A and B, and handler 2 with upstream C. Upstream C is healthy, but both A and B are down. If you just look at the upstream pool, it would look like it’s healthy overall because C is healthy, but handler 1 is unhealthy because both its upstreams are unhealthy.
If a handler is a set of upstreams, you could just query the upstreams health and look at the ones you’re interested in, maybe? I don’t know if the concept of a “handler” being “healthy/unhealthy” makes a lot of sense though – it’s really just a combination of upstreams’ health statuses.
It is exactly what we were looking for! I will test it during the next coming days and keep you updated. Great work! Caddy is a pleasure working with, we are currently building our new stack with Caddy replacing our existing webserver / reverse proxy.
Can you guide me to build the latest caddy with your fix for the upstream status? I had hoped to build with xcaddy, but i can simple not figure out how to get master, i constantly get the 2.3.0 version