Any way to get metrics on 2019 port?
inside caddy-proxy container config/caddy/autosave.json show
{"admin":{"listen":"tcp/localhost:2019"}
but with exposed 2019 port on docker-compose file, i can't connect to 2019, responce is:
Connection reset by peer
need advice - how change this settings to
{"admin":{"listen":":2019"}
or any other way to expose hostip:2019/metrics with lucaslorentz/caddy-docker-proxy and docker-compose ?
CDP needs control of the admin endpoint because it does managed config reloads.
You can serve metrics from any port with the metrics directive: https://caddyserver.com/docs/caddyfile/directives/metrics
Just add labels to your Caddy container to produce config like this:
:2020 {
metrics
}
thanks for answer! can you help with label example of this? have not idea how do it right way... may be or wrong?
labels:
caddy.handle_path: /metrics
caddy.handle_path.0_reverse_proxy: {{upstreams 2020}}
No, you need to define a site (like if you used a domain) but with :2020 instead. No reverse_proxy.
clear!
labels:
caddy_0:
caddy_0.servers:
caddy_0.servers.metrics:
caddy_1: ":2020"
caddy_1.metrics: "/metrics"
caddy_1.metrics.disable_openmetrics:
thank a lot
Can we also expose /reverse_proxy/upstreams in similar way?
Unfortunately no @m0n0chr0me. But you could do something silly like this:
:2020 {
handle /reverse_proxy/upstreams {
reverse_proxy localhost:2019
}
handle {
# fallback for other paths
}
}
Thank you @francislavoie. I tried this and I was getting the error
{"error":"host not allowed: caddy-docker-proxy:2020"}
So I have checked with chatgpt to find the below solution which is working fine. Thank you for your guidance.
:2020 {
handle /reverse_proxy/upstreams {
reverse_proxy localhost:2019 {
header_up Host localhost:2019
}
}
Equivalent labels would be
labels:
- caddy_1=:2020
- caddy_1.handle=/reverse_proxy/upstreams
- caddy_1.handle.reverse_proxy=localhost:2019
- caddy_1.handle.reverse_proxy.header_up=Host localhost:2019
And also need to expose 2020 in the ports section. Now i can load the caddy widget from Homepage.