Hello!
Help me please migrate from Nginx to Caddy v2. I have nginx config with few upstreams and Hash load balace policy based on $arg_NAME. How I can do this in Caddy v2? I did’t find example in Docs.
I still don’t understand what you mean by “args”. That’s vague. How is the URI parsed? Show an example request (i.e. a URI you would receive on your server) and what the “arg” would be in that case.
But yes, the uri_hash policy doesn’t take arguments. It hashes the entire URI and the same URI will reach the same upstream, consistently.
What I need. Web server can accept requests with different path or fragment but with same argument like ?hello=world in uri. All this requests must be forwarded to one backend. In nginx configuration I can set lb policy hash and set var $arg_NAME where NAME is argument name. How I can do set same policy in Caddy?
I’m not sure that’s possible to predict. Load balancing uses a hashing algorithm given a value. If you provide a different value, there’s no way to predict it’ll end up at the same backend.
Also btw, the URI fragment (i.e. the #frag part) never gets sent to the server. That’s client-side only. It’s impossible to route based on the fragment.
If you want to route specific query params to a specific upstream, you probably want to use the map directive instead: