我们使用 YARP 将请求路由到不同的端点。我们有一个要求,任何以“/secured”开头的 URL 都应该转发到特定的集群端点。例如以下所有路径都需要发送到cluster1
为了实现这一目标,我们配置如下路线:
{
"AllowedHosts": "*",
"ReverseProxy": {
"Routes": {
"route1" : {
"ClusterId": "cluster1",
"Match": {
"Path": "/secured{any1}"
}
},
"route2" : {
"ClusterId": "cluster1",
"Match": {
"Path": "/secured{any1}/{*any}"
}
},
"route3" : {
"ClusterId": "cluster1",
"Match": {
"Path": "/secured/{*any}"
}
}
},
"Clusters": {
"cluster1": {
"Destinations": {
"destination1": {
"Address": "https://secured.com/"
}
}
}
}
}
}
我们可以将路径配置为匹配上面指定的所有路由的模式吗?我已经尝试过下面的配置,但它不起作用。我想减少路由规范的数量,使配置更短。
"Path": "/secured(.*)"
用途:
/secured/{**catch-all}
这将与 /secured 之后的 URL 其余部分匹配