Open huluxia opened 1 year ago
You're gonna have to be more specific. That's way too vague. Please explain in detail what you mean. Show some examples.
You're gonna have to be more specific. That's way too vague. Please explain in detail what you mean. Show some examples.
Can the lb_policy of reverse_proxy customize hash calculation, for example, can I perform uri_hash calculation based on the specified part of uri instead of the entire uri, such as /path/0 and /path/1, my needs are as long as /path is the same, so whether it is / path/0 and /path/1 next time the same request, go to the backend server allocated last time
Interesting. That's not currently possible, but we could implement a policy that takes placeholders as input to be replaced. You could pair it with a path_regexp
matcher to pull out the bits of the path you need. But if you use a matcher, you have to take care of handling the base case where it doesn't match which can be tricky.
In the short term, I recommend writing a plugin that does what you need. LB policies are pluggable, so you can make it do exactly what you need yourself. See https://caddyserver.com/docs/extending-caddy, existing policy modules are defined here https://github.com/caddyserver/caddy/blob/master/modules/caddyhttp/reverseproxy/selectionpolicies.go
thank you!Hope caddy can add this feature in the future.
@francislavoie are we still interested in implementing this?
Sure, we can add it. I'm not sure how it'll look yet so if you make a prototype we can iterate on it 👍 thanks!
Why can't add lb_policy hash as custom in caddy