-
-
Notifications
You must be signed in to change notification settings - Fork 83
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
Dynamic proxy based on SNI #241
Comments
So basically the SNI matcher needs to support regex, I guess? Or a new |
That's one of the things. And the other, reference those attributes, so it can be "reused". Even better, if we're able to use basic functions like split or array acces, we could "construct" proxy destination from sni string. Something like:
Im not fluent in Go, but the idea is simple: regex on SNI for matching and then accessing what was matched (and if possible, manipulate/parse it) |
Hi! My 2 cents:
You may also implement your own |
I'm using something like this in my Caddyfile to perform SRV lookups to identify backends for HTTP: *.srv.example.com {
map {host} {consul_service} {
~(.*)\.srv\.example\.com$ "${1}.service.consul"
}
reverse_proxy {
dynamic srv {consul_service} {
resolvers "10.10.10.10"
}
}
} Being able to do the same for L4 would be amazing. |
I'm trying out the new 1. Unable to obtain matching results
2.
|
I think you should try double escaping as suggested in caddyserver/caddy#6569, i.e.
And this is a current design limitation, since the port is parsed and converted from string to integer after static placeholders are replaced (e.g. It's definitely possible to implement the dynamic port number feature, but it will require many changes to the code. PRs are welcome. |
I have tried this, but double escaping will cause the match to fail. The log shows
Adding an option to recognize that the upstream is a dynamic address and make changes accordingly might be a good solution with less changes. |
@lelemka0 Let's make sure we are testing the same software. What version of Caddy do you use? I suppose Update: yes, you are right, I see where the problem is. |
This is why
@mholt, Hi, What do you think about it? |
I think this PR #289 will support dynamic port numbers. |
Good analysis @vnxme -- thanks.
Yeah, in fact, this would result in an import cycle which wouldn't compile. There is a way to add indirection though, by an interface type for a method like Still not my favorite. I wonder if we should petition the Go team for a way to set that unexported context, like you can with |
Nice idea, thanks. Will require changes in both |
Sounds good for now. Thank you 😃 |
@lelemka0 Please try caddyserver/caddy#6804 and #290. This is the config I've tested locally.
|
@vnxme it works. |
Hello.
Related to #240, there are any way to route traffic based on the SNI? For example:
Instead of static configuration like this:
Have the app routed directly based on the SNI. Maybe similar to this:
The idea behind is that there will be multiple instances of the app, and the client could route based on the SNI value. Im not sure how ports treatement could be possible (or regex/parser of the sni), but at least using the sni directly could reduce a lot the config redundancy.
The text was updated successfully, but these errors were encountered: