-
-
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 proxy feature #2100
Comments
Pinging @Gufran - can you help here? |
I did have some code investigations I've done which I can share. I could not figure out how to get the dialer to work though |
Let me address the questions raised in discourse thread.
This is not what Caddy is supposed to do. First off, this behaviour ties your internal service registry with external traffic handlers and even with clients. And second, there is no way for caddy to know that resolving with
The code uses the function
Failover, target priority, and target weight are handled by DNS resolver. https://golang.org/src/net/lookup.go?s=11084:11167#L335
I am not sure if by
Now to answer your original question: You need to make sure that the configuration contains a valid domain.
then you can add or remove upstreams in service registry and change weightage and priority without ever changing the configuration. |
@Gufran could you propose some documentation changes to clarify this stuff for the future? |
This is a great explanation @Gufran, thanks. @francislavoie : To be fair, I believe at least some of that is "expected" to be known by those who are using SRV records. I don't use SRV, so I'm not sure, but it seems like a lot of that is out of the scope of the Caddy documentation. Maybe the few Go-specific or Caddy-implementation-specific quirks mentioned in your explanation could/should be mentioned in the docs? If so, I'm willing to make the changes, just tell me what the wording should be. But let's not get out of scope and explain how DNS and SRV works in general. 👍 |
@Gufran :
I'm not sure what you're trying to say there and how using SRV records means that at all.
I certainly meant #2 as we were discussing the results of the lookup and how the code only ever uses the first entry
I don't believe you can adjust weightage and priorty in the service registry to shape traffic because the code only ever use the top most entry in the dns result. I don't believe SRV records are being used in caddy how they're expected to be by anyone who sees it supports SRV records. If I list multiple SRV entries in DNS it implies I am expecting it to handle failover and load balancing. Yes the golang resolver sorts the records and randomizes them within a given priority but it does still return all of the records. What is presently in the code only handles load balancing if you set all of the priorities to be the same. It definitely doesn't handle failover as far as I can see. Back to my original suggestion which was to enhance what caddy could do when using SRV records, for someone who does follow the SRV rfc, and properly formats their dns configuration and doesn't want to list every domain in caddy and yet can have one configuration setting which will handle any hostname requested of it by looking up in DNS and retrieving the SRV record and getting the backend service for that hostname to proxy to. I'm not sure why you wouldn't want it to be able to do that when it doesn't seem to me to be that much of a change based on my investigation not being a caddy or go expert I got 90% of the way to actually making it work. |
Could you please ask a specific question? I'm not sure how to address this.
I see your point here. This is a deficiency in Caddy if you wish to have an elaborated setup with target weightage and priorities. I believe this can be discussed in a separate thread and someone can implement a load balancing algorithm for it.
I think you are confusing health checks with discovery. If you have a bunch of targets registered in DNS then the client is supposed to work with all of them. If some of the targets are unhealthy then that is a problem at some other level. ideally the service or the registry should keep the list of available targets up to date depending on their health. Consul catalog is a good example of this.
It looks like you want some sort of variable substitution behaviour in configuration block where you can dynamically choose service name to look up in registry for every request. This behaviour has nothing to do with SRV or Caddy.
Could you please propose a pull request with those changes so that everyone can get a better idea of the behaviour you are trying to describe? @mholt @francislavoie I agree with @mholt that this is out of scope of Caddy documentation. |
Great, sounds good to me. If further discussion is needed, feel free, but at this point it seems to be just a discussion rather than something specific and actionable in Caddy, so I will close the issue. Thanks! |
see relevant discussion here: https://caddy.community/t/dns-srv-record-support-in-proxy-directive/3592/7
1. What version of Caddy are you using (
caddy -version
)?latest version
2. What are you trying to do?
use the srv record feature of the proxy directive to handle multiple backends and multiple domains with one configuration entry
The text was updated successfully, but these errors were encountered: