配置多个web应用程序



我有两个web(不是api,假设剃刀)应用程序。我正试着把它们放在yp反向代理的后面。

这是我的配置:

"Yarp": {
"Routes": {
"web-route1": {
"ClusterId": "web-cluster1",
"Match": {
"Path": "/web1/{**catch-all}"
},
"Transforms": [
{ "PathPrefix": "/web1" }
]
},
"web-route2": {
"ClusterId": "web-cluster2",
"Match": {
"Path": "/web2/{**catch-all}"
},
"Transforms": [
{ "PathPrefix": "/web2" }
]
}
},
"Clusters": {
"web-cluster1": {
"Destinations": {
"destination1": {
"Address": "http://localhost:5135/"
}
}
},
"web-cluster2": {
"Destinations": {
"destination1": {
"Address": "http://localhost:5022/"
}
}
}
}

假设Yarp应用程序位于http://localhost:5000。目标是让应用程序相应地响应http: http://localhost:5000/web1和http://localhost:5000/web2。

不用说,它不起作用。有人有成功的经验吗?

我尝试了PathRemovePrefix,它适用于单个应用程序,但它显然删除了关键的前缀。

修改

"Transforms": [
{ "PathPrefix": "/web2" }
]

"Transforms": [
{ "PathPrefix": "{**catch-all}" }
]

您需要将{ "PathPrefix": "/web1" }更改为{ "PathRemovePrefix": "/web1" }

{
"Routes": {
"web-route1": {
"ClusterId": "web-cluster1",
"Match": {
"Path": "/web1/{**catch-all}"
},
"Transforms": [
{ "PathRemovePrefix": "/web1" }
]
},
"web-route2": {
"ClusterId": "web-cluster2",
"Match": {
"Path": "/web2/{**catch-all}"
},
"Transforms": [
{ "PathRemovePrefix": "/web2" }
]
}
},
"Clusters": {
"web-cluster1": {
"Destinations": {
"destination1": {
"Address": "http://localhost:5135/"
}
}
},
"web-cluster2": {
"Destinations": {
"destination1": {
"Address": "http://localhost:5022/"
}
}
}
}
}

相关内容

  • 没有找到相关文章

最新更新