Ocelot 入门Demo系列(01-Ocelot极简单Demo及负载均衡的配置) (2)

Ocelot 入门Demo系列(01-Ocelot极简单Demo及负载均衡的配置)

内容如下(最简单的配置,采用默认路由模板):

1 { 2 "ReRoutes": [ 3 { 4 // - 上游服务配置 5 "UpstreamPathTemplate": "/{url}", 6 "UpstreamHttpMethod": [ "Get", "Post", "Put", "Delete" ], 7 8 // - 下游服务配置 9 "DownstreamPathTemplate": "/{url}", 10 "DownstreamScheme": "http", 11 "DownstreamHostAndPorts": [ 12 { 13 "Host": "localhost", 14 "Port": 39991 15 }, 16 { 17 "Host": "localhost", 18 "Port": 39992 19 }, 20 { 21 "Host": "localhost", 22 "Port": 39993 23 } 24 ], 25 26 // - LoadBalancer将决定负载均衡的算法,三种取值 27 // RoundRobin:轮流发送 28 // LeastConnection:将请求发往最空闲的那个服务器 29 // NoLoadBalance:总是发往第一个请求或者是服务发现 30 "LoadBalancerOptions": { 31 "Type": "RoundRobin" 32 } 33 } 34 ], 35 "GlobalConfiguration": { 36 "BaseUrl": "https://api.mybusiness.com" 37 } 38 }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/zyjssd.html