我已经使用 .net Core 5.0 创建了一个反向代理,到目前为止它可以工作。现在我想根据请求的 URL 更改目标。这是我的 appsettings.json:
"ReverseProxy": {
"Routes": [
{
"RouteId": "route1",
"ClusterId": "cluster1",
"Match": {
"Path": "{**catch-all}"
}
}
],
"Clusters": {
"cluster1": {
"Destinations": {
"cluster1/destination1": {
"Address": "http://192.168.178.36"
}
}
},
"cluster2": {
"Destinations": {
"cluster1/destination1": {
"Address": "http://localhost:8080/signalr"
}
}
}
}
据我所知,所有请求都转发到我的网络服务器。但是,如果有人使用路径 /signalr 启动请求,则应该将其转发到我的 Signalr 服务器。 我也尝试过使用谷歌,但据我所知,与 appsettings.json 相关的文档到目前为止非常糟糕。
答案 0 :(得分:0)
我找到了答案,我的新 apssettings.json:
"ReverseProxy": {
"Routes": [
{
"RouteId": "signalrServer",
"ClusterId": "signalrServer",
"Match": {
"Path": "/signalr/{**catch-all}"
}
},
{
"RouteId": "mediaserver",
"ClusterId": "mediaserver",
"Match": {
"Path": "/live/{**catch-all}"
}
},
{
"RouteId": "default",
"ClusterId": "default",
"Match": {
"Path": "{**catch-all}"
}
}
],
"Clusters": {
"default": {
"Destinations": {
"notfound": {
"Address": "http://192.168.178.41/system/error/NotFound"
}
}
},
"mediaserver": {
"Destinations": {
"mediaserver": {
"Address": "http://192.168.178.36"
}
}
},
"signalrServer": {
"Destinations": {
"signalrServer": {
"Address": "http://localhost:8080"
}
}
}
}