繁体   English   中英

ASP.NET Core YARP 反向代理多个监听端口

[英]ASP.NET Core YARP Reverse Proxy multiple listen ports

我想用 YARP 反向代理多个端口。

0.0.0.0:5001  =>  RemoteHost.com:7001
0.0.0.0:5002  =>  RemoteHost.com:7002
0.0.0.0:5003  =>  RemoteHost.com:7003
0.0.0.0:5004  =>  RemoteHost.com:7004

所有示例似乎都映射了 URL,而不是端口。

public class ProxyConfigProvider : IProxyConfigProvider
{

var routeConfig = new RouteConfig
{
       RouteId = "route1",
       ClusterId = "cluster1",
       Match = new RouteMatch
       {
           Path = "/api/service1/{**catch-all}"
       }
};

var clusterConfig = new ClusterConfig
  {
      Destinations = new [] = {"Address": "https://RemoteHost.com:7001"}
....

你如何设置 Kestrel 和 YARP 来做我想做的事?

您可以使用 Hosts 字段按端口路由

"Match": {
  "Hosts" : [ "*:5001" ]

您还需要告诉 kestrel 监听这些端口。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM