Handling two clusters with same path in YARP - how to route API requests correctly? #2610
-
|
Hi, I'm working with YARP and have a setup where two clusters have the same route path, but they need to forward to different service. appsettings.json "ReverseProxy": { |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
What criteria should be used to distinguish between the routes? Host name, query, headers, random, etc.? |
Beta Was this translation helpful? Give feedback.
I'm not sure I completely understand your setup, but if you want to route requests differently depending on their host header, you can specify the
Hostsjust as you're already doing withPathandMethods, e.g."req1_route1": { "ClusterId": "clusterId1", "Match": { "Path": "/path1/{**remainder}", "Methods": [ "GET", "POST" ], + "Hosts": [ "www.foo" ] } }, "req2_route1": { "ClusterId": "clusterId2", "Match": { "Path": "/path1/{**remainder}", "Methods": [ "GET", "POST" ], + "Hosts": [ "www.bar" ] } },