How can I know which backend Caddy dialed up?

1. Caddy version (caddy version):

v2.4.6 h1:HGkGICFGvyrodcqOOclHKfvJC0qTU7vny/7FhYp9hNw=

2. How I run Caddy:

Use systemd

a. System environment:

Ubuntu 20.04.3

b. Command:

Paste command here.

c. Service/unit/compose file:

Paste full file contents here.
Make sure backticks stay on their own lines,
and the post looks nice in the preview pane.

d. My complete Caddyfile or JSON config:

https://*.buct.edu.cn {
	reverse_proxy * https://backend-1 https://backend-2 {
        # header_down X-Backend-Server {http.request.header.X-Caddy-Upstream-Dial}
		transport http {
			tls_insecure_skip_verify
		}
	}

3. The problem Iā€™m having:

I use Caddy as a Load Balancer, But how can I know which backend Caddy dialed up? Because I want to find which backend instance raise an error in an easy way.

4. Error messages and/or full log output:

5. What I already tried:

For example, Caddy can respond a page with header which it dialed up, I have tried add a header, but it didn`t work.

header_down X-Backend-Server {http.request.header.X-Caddy-Upstream-Dial}

6. Links to relevant resources:

You can use any of these 3 placeholders:

{http.reverse_proxy.upstream.address}
{http.reverse_proxy.upstream.hostport}
{http.reverse_proxy.upstream.host}
1 Like

Thank you! It works.
And how can I get an appropriate placeholder? Does caddy have a list of placeholds? I tried, but I can`t find it on Caddy Documentation.

They are mentioned on this page:

But I agree they should also be added to the page for the Caddyfile directive as well.

This topic was automatically closed after 30 days. New replies are no longer allowed.