Use domain name metric can't work properly on https mode

as title, when i setting the GitHub - gethomepage/homepage: A highly customizable homepage (or startpage / application dashboard) with Docker and service API integrations. 's widget service, it will get data by https://caddy.nebulosa-cat.me/reverse_proxy/upstreams, and it got a blank output.

but the output on https://caddy.nebulosa-cat.me is normal show the metrics data (on desktop not on the host device).

# HELP caddy_admin_http_requests_total Counter of requests made to the Admin API's HTTP endpoints.
# TYPE caddy_admin_http_requests_total counter
caddy_admin_http_requests_total{code="200",handler="load",method="POST",path="/load"} 9
caddy_admin_http_requests_total{code="200",handler="reverse_proxy",method="GET",path="/reverse_proxy/upstreams"} 2
# HELP caddy_http_request_duration_seconds Histogram of round-trip request durations.
# TYPE caddy_http_request_duration_seconds histogram
...

my caddy is host on rpi4b on pi os bulleye
and it have cloudflare plugin (use xcaddy)
it’s version is v2.7.6 h1:w0NymbG2m9PcvKWsrXO6EEkY9Ru4FJK8uQbYcev1p3A=

my Caddyfile:

caddy.nebulosa-cat.me {
	metrics /
	tls admin@nebulosa-cat.com {
		dns cloudflare api-token
	}
}
sub-store.nebulosa-cat.me {
	reverse_proxy http://127.0.0.1:3001
	tls admin@nebulosa-cat.com {
		dns cloudflare api-token
	}
}
wol.nebulosa-cat.me {
	reverse_proxy localhost:8090
	tls admin@nebulosa-cat.com {
		dns cloudflare api-token
	}
}

on the device i’m host cady (in here is Pi4b)

input : curl http://localhost:2019/
output:

404 page not found

input : curl http://localhost:2019/metrics
output:

# HELP caddy_admin_http_requests_total Counter of requests made to the Admin API's HTTP endpoints.
# TYPE caddy_admin_http_requests_total counter
caddy_admin_http_requests_total{code="200",handler="load",method="POST",path="/load"} 9
caddy_admin_http_requests_total{code="200",handler="reverse_proxy",method="GET",path="/reverse_proxy/upstreams"} 2
# HELP caddy_http_request_duration_seconds Histogram of round-trip request durations.
# TYPE caddy_http_request_duration_seconds histogram
...

input: curl http://localhost:2019/reverse_proxy/upstreams
output:

[{"address":"localhost:8090","num_requests":0,"fails":0},{"address":"127.0.0.1:3001","num_requests":0,"fails":0}]

input: curl https://caddy.nebulosa-cat.me/
output:

# HELP caddy_admin_http_requests_total Counter of requests made to the Admin API's HTTP endpoints.
# TYPE caddy_admin_http_requests_total counter
caddy_admin_http_requests_total{code="200",handler="load",method="POST",path="/load"} 9
caddy_admin_http_requests_total{code="200",handler="reverse_proxy",method="GET",path="/reverse_proxy/upstreams"} 2
# HELP caddy_http_request_duration_seconds Histogram of round-trip request durations.
# TYPE caddy_http_request_duration_seconds histogram
...

input: curl https://caddy.nebulosa-cat.me/metrics
output: blank

input: curl https://caddy.nebulosa-cat.me/caddy_reverse_proxy_upstreams
output: blank

input: curl https://caddy.nebulosa-cat.me/metrics/caddy_reverse_proxy_upstreams
output: blank

is there any setting in Cadddyfile I miss ?
or it just only work in http mode? because if possible https normally better then http i think ?

That’s correct. There’s no route for / on the admin API.

This also looks correct. num_requests only shows the amount of currently active requests (i.e. still being processed). If there’s no current traffic, then it’ll show 0. And fails is 0 because you didn’t enable passive health checking and that’s needed to increment the counter for recent failed requests.

I don’t understand the question. What does this have to do with HTTP vs HTTPS?

It doesn’t seem like you enabled HTTP metrics. See the docs: Monitoring Caddy with Prometheus metrics — Caddy Documentation

oh…
so the config should use

{
    servers {
        metrics
    }
}

so i try this:

{
	servers {
		metrics
	}
}
caddy.nebulosa-cat.me {
	reverse_proxy localhost:2019
	tls admin@nebulosa-cat.com {
		dns cloudflare api-token
	}
}
...

(i also try reverse_proxy :2019 too, same result)

and it will got {"error":"host not allowed: caddy.nebulosa-cat.me"}
should i setting the admin in servers ?
but it look will also open manage feature in caddy to make remote host can use api to control the caddy, i only want get metrics data only

Why are you trying to proxy to the admin endpoint? That’s a terrible idea.

If admin is publicly reachable, anyone can change your server’s configuration. That’s extremely dangerous. Don’t do that.

The metrics directive (inside a site block) is to serve metrics. The servers > metrics global option is to enable metrics to be tracked.

yes, so i don’t wnat add the admin to globe option.

I’m try to bind domain is because i’m trying to setting a moniter widdget, and my home network doesn’t have static ip, i need to use ddns service bind my ip to a domain name to use it.

so as now in my unerstand, the servers > metrics is use to enable the metrics, and the metrics in site block is to send metrics data for who know the hostname.

so my config now is

{
	servers {
		metrics
	}
}
caddy.nebulosa-cat.me {
	metrics
	tls admin@nebulosa-cat.com {
		dns cloudflare api-token
	}
}

so if this is correct, i shold able to see metrics data by use the caddy.nebulosa-cat.me

after setting like this and reload caddy serivce, it’s output was a little ddiffer then original porblem.

the output of curl http://localhost:2019/metric and curl http://localhost:2019/reverse_proxy/upstreams are correct (the front one output full metrics and the after one output the [{"address":"127.0.0.1:3001","num_requests":0,"fails":0},{"address":"localhost:8090","num_requests":0,"fails":0}]

but the hostname’s output look not correct:
curl caddy.nebulosa-cat.me/metrics
of course this will show full metrics, and in local terminal or browser i can see this output have caddy_admin_http_requests_total{code="200",handler="reverse_proxy",method="GET",path="/reverse_proxy/upstreams"} 5 so it should can see the /reverse_proxy/upstreams metrics data ?

but in curl caddy.nebulosa-cat.me/reverse_proxy/upstreams or curl caddy.nebulosa-cat.me/any-input-here
it all show the same output as when it ending as /metric

# HELP caddy_admin_http_requests_total Counter of requests made to the Admin API's HTTP endpoints.
# TYPE caddy_admin_http_requests_total counter
caddy_admin_http_requests_total{code="200",handler="load",method="POST",path="/load"} 24
caddy_admin_http_requests_total{code="200",handler="metrics",method="GET",path="/metrics"} 3
caddy_admin_http_requests_total{code="200",handler="reverse_proxy",method="GET",path="/reverse_proxy/upstreams"} 5
# HELP caddy_http_request_duration_seconds Histogram of round-trip request durations.
# TYPE caddy_http_request_duration_seconds histogram
caddy_http_request_duration_seconds_bucket{code="200",handler="subroute",method="GET",server="srv0",le="0.005"} 155
caddy_http_request_duration_seconds_bucket{code="200",handler="subroute",method="GET",server="srv0",le="0.01"} 224
...

is this work right or it should output [{"address":"127.0.0.1:3001","num_requests":0,"fails":0},{"address":"localhost:8090","num_requests":0,"fails":0}] when use https://caddy.nebulosa-cat.me/reverse_proxy/upstreams?

Metrics is not the same as the proxy upstreams admin endpoint. Totally different purposes, separate code/logic. They’re not related to eachother.

What are you actually trying to do here? You haven’t explained you goal.

https://xyproblem.info/

sorry my english skill was very poor, the begin i say is what i trying and want to get maybe not in a clear format

this widget will try to get data from caddy.host or ip:port

    - Caddy:
        icon: caddy.png
        description: Reverse proxy and auto SSL.
        widget:
            type: caddy
            url: https://caddy.nebulosa-cat.me

so i trying to make https://caddy.nebulosa-cat.me/reverse_proxy/upstreams output correct format data like
[{"address":"127.0.0.1:3001","num_requests":0,"fails":0},{"address":"localhost:8090","num_requests":0,"fails":0}]

But why do you need that information? What are you trying to do with it?