-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
SRV lookups only use first response #4174
Comments
Please elaborate, I don't think there's really enough detail to make this actionable. PRs welcome, if you know the fix that needs to be made. |
An SRV lookup returns all SRV entries. Each entry has a priority and a weight. A correct use of that response should group the entries by priority and attempt to use the top (numerically lowest) priority entries first. Their respective weights should define their odds of getting picked. Once the top priority group is exhausted with no succesful reply, only then should we move on to the next group. However, Caddy will only use a single entry, namely the first one. Even with many SRV entries, an incoming request will fail to be served correctly if the first entry happens to be one for a server that is unhealthy. |
I think you need to enable https://caddyserver.com/docs/caddyfile/directives/reverse_proxy#load-balancing |
The gold plated way to address this would be:
|
|
For clarity, I understand that most people probably have Consul or something similar maintaining their SRV records, so you should never get SRV entries for unhealthy backends. In that case, everything is fine. My use case is somewhat different. |
This kinda goes hand-in-hand with #1545 |
Jotting down thoughts as I took glances at the code to understand what it could touch:
|
I'm working on this. |
@sorenisanerd Would you like to give my PR, #4470, a try? It only supports JSON config for now, but you can just use |
I would love to, but I discarded the experiment I was doing and canned the project, so I don't have backend servers, name servers, or anything else that I'd need to try it out. Sorry :( |
Done in #4470. |
caddy/modules/caddyhttp/reverseproxy/hosts.go
Line 152 in e3c369d
Even if the the DNS randomizes the order of entries (while still observing priorities), it's still perfectly possible for all the top-priority servers to be at capacity, in which case the we should move on to entries with lower priority.
The text was updated successfully, but these errors were encountered: