Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any way to get metrics on 2019 port? #613

Open
andreevgrisha opened this issue May 6, 2024 · 7 comments
Open

Any way to get metrics on 2019 port? #613

andreevgrisha opened this issue May 6, 2024 · 7 comments

Comments

@andreevgrisha
Copy link

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 ?

@francislavoie
Copy link
Collaborator

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
}

@andreevgrisha
Copy link
Author

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}}

@francislavoie
Copy link
Collaborator

No, you need to define a site (like if you used a domain) but with :2020 instead. No reverse_proxy.

@andreevgrisha
Copy link
Author

andreevgrisha commented May 6, 2024

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

@m0n0chr0me
Copy link

Can we also expose /reverse_proxy/upstreams in similar way?

@francislavoie
Copy link
Collaborator

francislavoie commented Aug 30, 2024

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
	}
}

@m0n0chr0me
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants