简体   繁体   English

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

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

I want to Reverse Proxy multiple ports, with YARP.我想用 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

All the examples seem to map URLs, and not ports.所有示例似乎都映射了 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"}
....

How do you set up Kestrel and YARP to do what I want?你如何设置 Kestrel 和 YARP 来做我想做的事?

You can route by port using the Hosts field您可以使用 Hosts 字段按端口路由

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

You also need to tell kestrel to listen on those ports.您还需要告诉 kestrel 监听这些端口。

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

相关问题 具有Apache和反向代理的Linux ASP.Net核心 - Linux ASP.Net core with Apache and reverse proxy 如何使用集群内反向代理自动确定在Kubernetes中运行的ASP.NET Core应用程序的KnownNetworks? - How to automatically determine KnownNetworks for ASP.NET Core application running in Kubernetes with an in-cluster reverse proxy? 反向代理后面的 ASP.Net Core 不使用 `X-Forwareded-For` - `X-Forwareded-For` is not used by ASP.Net Core behind reverse proxy ASP.NET Core Razor 在使用 Apache 作为反向代理时无法设置 cookie - ASP.NET Core Razor unable to set cookies when using Apache as reverse proxy ASP.NET Core 404 响应中的 Servce Fabric 反向代理集成 - Servce Fabric Reverse Proxy Integration in ASP.NET Core 404 Response ASP.NET Core 3.1 with google signin,nginx反向代理和docker资源暂时不可用 - ASP.NET Core 3.1 with google signin, nginx reverse proxy and docker Resource temporarily unavailable Yarp 反向代理 - 响应 502 错误网关 - Yarp Reverse Proxy - Response 502 Bad Gateway Stackify在ASP.NET Core中未使用代理 - Stackify not using proxy in ASP.NET Core 监听 mTLS ASP.NET Core 的多个端口 - Listening on many ports for mTLS ASP.NET Core How to set BaseUrl for Swagger in ASP.NET Core Web API using NSwag.AspNetCore (when hosted behind a reverse proxy) - How to set BaseUrl for Swagger in ASP.NET Core Web API using NSwag.AspNetCore (when hosted behind a reverse proxy)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM