Have different upstream weights for load balancing

1. Output of caddy version:

$ caddy version
v2.6.2 h1:wKoFIxpmOJLGl3QXoo6PNbYvGW4xLEgo32GPBEjWL8o=

2. How I run Caddy:

sudo caddy run # with a Caddyfile

a. System environment:

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 Caddy config:

abc.xyz:443 {
	reverse_proxy IP_ADDR1 IP_ADDR2 IP_ADDR3 {
		lb_policy least_conn
		health_uri "/health"
		health_interval 3s
		health_timeout 7s

3. The problem I’m having:

I’m not sure how to assign weights to upstream. So, there’d be a 60-30-10 distribution. Or, even a 50-50-0 distribution, where the third IP is just in case both the first two fail (purely as a last resort backup).

4. Error messages and/or full log output:

Paste logs/commands/output here.

5. What I already tried:

6. Links to relevant resources:

There’s no way to set weights currently with static upstreams.

But the dynamic SRV upstreams provider can provide weights:

You could write your own dynamic upstreams plugin to do this if you like. Take a look at the source code for the SRV upstreams provider, and you can probably reuse a lot of that code to do it.

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