test.dreamwalkers.dk {
reverse_proxy {
to host1:8080
to host2:8080
health_path /foo/health
health_interval 1s
health_body "(OK)"
}
}
3. The problem I’m having:
How can i query caddy for the upstream health status ? Like i would like to know if caddy see that both hosts in my config are UP
4. Error messages and/or full log output:
N/A
5. What I already tried:
curl localhost:2019/config/ but that will only give me the config, i would like to see the health status seen from Caddy, this could be a combined status from active + passive monitoring
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.
I feel it would be sorta funky to reference though, cause you might have multiple reverse_proxy handlers each with their own upstream pools. How would you uniquely identify the handler?
The upstreams are deliberately global, and are shared between handlers, because there is only ever 1 of any given upstream, even if multiple handlers refer to it.
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.
Matt, thanks for your input, yes basically for my use case, we want to make a query, and get all the upstreams health and look at the ones we are interrested in.
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