Files
Yi.Admin/Yi.Framework.Net6/Yi.Framework.OcelotGateway/configuration.json

433 lines
15 KiB
JSON
Raw Normal View History

2023-01-02 14:29:16 +08:00
////*****************************单地址多实例负载均衡+Consul********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
2023-01-02 14:29:16 +08:00
// "ServiceName": "ZhaoxiService", //consul服务名称
2022-04-07 22:48:10 +08:00
// "LoadBalancerOptions": {
2023-01-02 14:29:16 +08:00
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
2022-04-07 22:48:10 +08:00
// }
// }
// ],
// "GlobalConfiguration": {
2023-01-02 14:29:16 +08:00
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
2022-04-07 22:48:10 +08:00
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
2023-01-02 14:29:16 +08:00
// "Type": "Consul" //由Consul提供服务发现, 每次请求去consul
// } //Ocelot没有支持配置多个Consul
2022-04-07 22:48:10 +08:00
// //,"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
2023-01-02 14:29:16 +08:00
// // "Type": "PollConsul", //由Consul提供服务发现,
// // "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// // //"Token": "footoken"//需要ACL的话
2022-04-07 22:48:10 +08:00
// //}
// }
//}
//*****************************Ocelot+Consul********************************
{
"Routes": [
{
2023-01-02 14:29:16 +08:00
"UpstreamPathTemplate": "api/api/{url}", //上游请求地址--网关
2022-04-07 22:48:10 +08:00
"UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ],
"UseServiceDiscovery": true,
"ServiceName": "ApiMicroservice",
"LoadBalancerOptions": {
2023-01-02 14:29:16 +08:00
"Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
2022-04-07 22:48:10 +08:00
},
2023-01-02 14:29:16 +08:00
"DownstreamPathTemplate": "api/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
"DownstreamScheme": "https",
"DownstreamHeaderTransform": {
2023-01-02 14:29:16 +08:00
"Access-Control-Allow-Origin": "*", //不存在就添加
2022-04-07 22:48:10 +08:00
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "*"
}
},
{
2023-01-02 14:29:16 +08:00
"UpstreamPathTemplate": "api/item/{url}", //上游请求地址--网关
2022-04-07 22:48:10 +08:00
"UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ],
"UseServiceDiscovery": true,
"ServiceName": "PageDetail",
"LoadBalancerOptions": {
2023-01-02 14:29:16 +08:00
"Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
2022-04-07 22:48:10 +08:00
},
2023-01-02 14:29:16 +08:00
"DownstreamPathTemplate": "api/item/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
"DownstreamScheme": "https",
"DownstreamHeaderTransform": {
2023-01-02 14:29:16 +08:00
"Access-Control-Allow-Origin": "*", //不存在就添加
2022-04-07 22:48:10 +08:00
"Access-Control-Allow-Methods": "*",
"Access-Control-Allow-Headers": "*"
}
}
],
"GlobalConfiguration": {
2023-01-02 14:29:16 +08:00
"BaseUrl": "http://127.0.0.1:7200", //网关对外地址
2022-04-07 22:48:10 +08:00
"ServiceDiscoveryProvider": {
"Host": "192.168.2.128",
"Port": 8500,
2023-01-02 14:29:16 +08:00
"Type": "Consul" //由Consul提供服务发现, 每次请求去consul
2022-04-07 22:48:10 +08:00
},
"RateLimitOptions": {
2023-01-02 14:29:16 +08:00
"QuotaExceededMessage": "你的请求过于频繁,请稍后再试!", // 当请求过载被截断时返回的消息
"HttpStatusCode": 666 // 当请求过载被截断时返回的http status
//"ClientIdHeader": "client_id" // 用来识别客户端的请求头,默认是 ClientId
2022-04-07 22:48:10 +08:00
}
//,"ServiceDiscoveryProvider": {
// "Host": "localhost",
// "Port": 8500,
2023-01-02 14:29:16 +08:00
// "Type": "PollConsul", //由Consul提供服务发现,
// "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// //"Token": "footoken"//需要ACL的话
2022-04-07 22:48:10 +08:00
//}
}
}
2023-01-02 14:29:16 +08:00
////*****************************单地址--无Consul********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/api/auth/{url}", //上游请求地址--网关
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post", "Put", "PATCH", "Delete", "Options" ],
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 7200 //网关api 端口
2022-04-07 22:48:10 +08:00
// }
// ],
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
// "DownstreamHeaderTransform": {
2023-01-02 14:29:16 +08:00
// "Access-Control-Allow-Origin": "*", //不存在就添加
2022-04-07 22:48:10 +08:00
// "Access-Control-Allow-Methods": "*",
// "Access-Control-Allow-Headers": "*"
// }
// }
// ]
//}
2023-01-02 14:29:16 +08:00
////*****************************单地址全匹配********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5726 //服务端口
2022-04-07 22:48:10 +08:00
// }
// ],
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/{url}", //网关地址--url变量 //冲突的还可以加权重Priority
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ]
// }
// ]
//}
2023-01-02 14:29:16 +08:00
////*****************************多地址多实例********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5726 //服务端口
2022-04-07 22:48:10 +08:00
// }
// ],
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/T5726/{url}", //网关地址--url变量
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ]
// },
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5727 //服务端口
2022-04-07 22:48:10 +08:00
// }
// ],
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/T5727/{url}", //网关地址--url变量
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ]
// },
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5728 //服务端口
2022-04-07 22:48:10 +08:00
// }
// ],
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/T5728/{url}", //网关地址--url变量
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ]
// }
// ]
//}
2023-01-02 14:29:16 +08:00
//////MVC的路由规则是近水楼台先得月--
////*****************************路由冲突+带权匹配********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5726 //服务端口
2022-04-07 22:48:10 +08:00
// }
// ],
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/{url}", //网关地址--url变量 //冲突的还可以加权重Priority
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ],
2023-01-02 14:29:16 +08:00
// "Priority": 0 //默认是0 加个1
2022-04-07 22:48:10 +08:00
// },
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/users/get?id={id}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5727 //服务端口
2022-04-07 22:48:10 +08:00
// }
// ],
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/api/users/get/{id}", //网关地址--url变量 //冲突的还可以加权重Priority
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ],
2023-01-02 14:29:16 +08:00
// "Priority": 1 //默认是0 加个1
2022-04-07 22:48:10 +08:00
// },
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/users/{url}?id={id}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5728 //服务端口
2022-04-07 22:48:10 +08:00
// }
// ],
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/api/users/{url}/{id}", //网关地址--url变量 //冲突的还可以加权重Priority
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ],
2023-01-02 14:29:16 +08:00
// "Priority": 2 //默认是0 加个1
2022-04-07 22:48:10 +08:00
// }
// ]
//}
2023-01-02 14:29:16 +08:00
////*****************************单地址多实例负载均衡********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "47.95.2.2",
// "Port": 5726
2023-01-02 14:29:16 +08:00
// }, //Ocelot负载均衡
2022-04-07 22:48:10 +08:00
// {
// "Host": "47.95.2.2",
// "Port": 5727
// },
// {
// "Host": "47.95.2.2",
// "Port": 5728
// }
// ],
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量 //冲突的还可以加权重Priority
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "LoadBalancerOptions": {
2023-01-02 14:29:16 +08:00
// "Type": "RoundRobin" //轮询 //"LeastConnection" //最少连接数的服务器 "NoLoadBalance" //不负载均衡 //"CookieStickySessions" //会话粘滞 //
2022-04-07 22:48:10 +08:00
// }
// //"LoadBalancerOptions": {
// // "Type": "CookieStickySessions",
// // "Key": "ASP.NET_SessionId",
// // "Expiry": 1800000
// //}
// }
// ]
//}
2023-01-02 14:29:16 +08:00
////*****************************单地址多实例负载均衡+Consul********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
2023-01-02 14:29:16 +08:00
// "ServiceName": "ZhaoxiService", //consul服务名称
2022-04-07 22:48:10 +08:00
// "LoadBalancerOptions": {
2023-01-02 14:29:16 +08:00
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
2022-04-07 22:48:10 +08:00
// }
// }
// ],
// "GlobalConfiguration": {
2023-01-02 14:29:16 +08:00
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
2022-04-07 22:48:10 +08:00
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
2023-01-02 14:29:16 +08:00
// "Type": "Consul" //由Consul提供服务发现, 每次请求去consul
// } //Ocelot没有支持配置多个Consul
2022-04-07 22:48:10 +08:00
// //,"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
2023-01-02 14:29:16 +08:00
// // "Type": "PollConsul", //由Consul提供服务发现,
// // "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// // //"Token": "footoken"//需要ACL的话
2022-04-07 22:48:10 +08:00
// //}
// }
//}
2023-01-02 14:29:16 +08:00
////*****************************Consul+缓存Cache********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
2023-01-02 14:29:16 +08:00
// "ServiceName": "ZhaoxiService", //consul服务名称
2022-04-07 22:48:10 +08:00
// "LoadBalancerOptions": {
2023-01-02 14:29:16 +08:00
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
2022-04-07 22:48:10 +08:00
// },
// "FileCacheOptions": {
// "TtlSeconds": 15, //Second
2023-01-02 14:29:16 +08:00
// "Region": "UserCache" //可以调用Api缓存清理
2022-04-07 22:48:10 +08:00
// }
// }
// ],
// "GlobalConfiguration": {
2023-01-02 14:29:16 +08:00
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
2022-04-07 22:48:10 +08:00
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
2023-01-02 14:29:16 +08:00
// "Type": "Consul" //由Consul提供服务发现, 每次请求去consul
2022-04-07 22:48:10 +08:00
// }
// //"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
2023-01-02 14:29:16 +08:00
// // "Type": "PollConsul", //由Consul提供服务发现,
// // "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// // //"Token": "footoken"//需要ACL的话
2022-04-07 22:48:10 +08:00
// //}
// }
//}
2023-01-02 14:29:16 +08:00
////*****************************超时+限流+熔断+降级+Consul+Polly********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
2023-01-02 14:29:16 +08:00
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
2022-04-07 22:48:10 +08:00
// "DownstreamScheme": "http",
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
2022-04-07 22:48:10 +08:00
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
2023-01-02 14:29:16 +08:00
// "ServiceName": "ZhaoxiService", //consul服务名称
2022-04-07 22:48:10 +08:00
// "LoadBalancerOptions": {
2023-01-02 14:29:16 +08:00
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
2022-04-07 22:48:10 +08:00
// },
// "RateLimitOptions": {
2023-01-02 14:29:16 +08:00
// "ClientWhitelist": [ "eleven", "seven" ], //白名单 ClientId 区分大小写
2022-04-07 22:48:10 +08:00
// "EnableRateLimiting": true,
// "Period": "5m", //1s, 5m, 1h, 1d
2023-01-02 14:29:16 +08:00
// "PeriodTimespan": 30, //多少秒之后客户端可以重试
// "Limit": 5 //统计时间段内允许的最大请求数量
2022-04-07 22:48:10 +08:00
// },
// "AuthenticationOptions": {
// "AuthenticationProviderKey": "UserGatewayKey",
// "AllowedScopes": []
// },
// "QoSOptions": {
2023-01-02 14:29:16 +08:00
// "ExceptionsAllowedBeforeBreaking": 3, //允许多少个异常请求
// "DurationOfBreak": 10000, // 熔断的时间单位为ms
// "TimeoutValue": 2000 //单位ms 如果下游请求的处理时间超过多少则自如将请求设置为超时 默认90秒
2022-04-07 22:48:10 +08:00
// }
// //"FileCacheOptions": {
// // "TtlSeconds": 15,
2023-01-02 14:29:16 +08:00
// // "Region": "UserCache" //可以调用Api清理
2022-04-07 22:48:10 +08:00
// //}
// }
// ],
// "GlobalConfiguration": {
2023-01-02 14:29:16 +08:00
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
2022-04-07 22:48:10 +08:00
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
2023-01-02 14:29:16 +08:00
// "Type": "Consul" //由Consul提供服务发现
2022-04-07 22:48:10 +08:00
// },
// "RateLimitOptions": {
2023-01-02 14:29:16 +08:00
// "QuotaExceededMessage": "Too many requests, maybe later? 11", // 当请求过载被截断时返回的消息
// "HttpStatusCode": 666, // 当请求过载被截断时返回的http status
// //"ClientIdHeader": "client_id" // 用来识别客户端的请求头,默认是 ClientId
2022-04-07 22:48:10 +08:00
// }
// }
//}
2023-01-02 14:29:16 +08:00
////*****************************请求聚合Aggregator********************************
2022-04-07 22:48:10 +08:00
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5726 //服务端口
// } //可以多个,自行负载均衡
2022-04-07 22:48:10 +08:00
// ],
// "UpstreamPathTemplate": "/T5726/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5726"
// },
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5727 //服务端口
2022-04-07 22:48:10 +08:00
// }
// ],
// "UpstreamPathTemplate": "/T5727/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5727"
// },
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
2023-01-02 14:29:16 +08:00
// "Port": 5728 //服务端口
2022-04-07 22:48:10 +08:00
// }
// ],
// "UpstreamPathTemplate": "/T5728/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5728"
// }
// ],
// "Aggregates": [
// {
// "RouteKeys": [
// "T5726",
// "T5727",
// "T5728"
// ],
2023-01-02 14:29:16 +08:00
// "UpstreamPathTemplate": "/UserAggregator", //如果某个404 是不影响返回当成null
// "Aggregator": "CustomUserAggregator" //自定义聚合器
2022-04-07 22:48:10 +08:00
// }
// ]
//}