-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfiguration.json
More file actions
416 lines (391 loc) · 13.8 KB
/
configuration.json
File metadata and controls
416 lines (391 loc) · 13.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
{
"Routes": [
{
"UseServiceDiscovery": true, //开启服务注册发现
"DownstreamPathTemplate": "/Tset/{url}", //服务地址--url变量
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/ServerA/{url}", //网关地址--url变量
"UpstreamHttpMethod": [ "Get", "Post" ],
"ServiceName": "ServerA", //consul服务名称
"LoadBalancerOptions": {
"Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
},
//限流
"RateLimitOptions": {
"ClientWhitelist": [], //白名单 ClientId 区分大小写
"EnableRateLimiting": true,
"Period": "30s", //1s, 5m, 1h, 1d
"PeriodTimespan": 30, //多少秒之后客户端可以重试
"Limit": 10 //统计时间段内允许的最大请求数量
}
},
{
"UseServiceDiscovery": true, //开启服务注册发现
"DownstreamPathTemplate": "/Tset/{url}", //服务地址--url变量
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/ServerB/{url}", //网关地址--url变量
"UpstreamHttpMethod": [ "Get", "Post" ],
"ServiceName": "ServerB", //consul服务名称
"LoadBalancerOptions": {
"Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
},
//限流
"RateLimitOptions": {
"ClientWhitelist": [], //白名单 ClientId 区分大小写
"EnableRateLimiting": true,
"Period": "30s", //1s, 5m, 1h, 1d
"PeriodTimespan": 20, //多少秒之后客户端可以重试
"Limit": 20 //统计时间段内允许的最大请求数量
}
},
{
"UseServiceDiscovery": true, //开启服务注册发现
"DownstreamPathTemplate": "/Tset/{url}", //服务地址--url变量
"DownstreamScheme": "http",
"UpstreamPathTemplate": "/ServerC/{url}", //网关地址--url变量
"UpstreamHttpMethod": [ "Get", "Post" ],
"ServiceName": "ServerC", //consul服务名称
"LoadBalancerOptions": {
"Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
},
//限流
"RateLimitOptions": {
"ClientWhitelist": [], //白名单 ClientId 区分大小写
"EnableRateLimiting": true,
"Period": "30s", //1s, 5m, 1h, 1d
"PeriodTimespan": 10, //多少秒之后客户端可以重试
"Limit": 30 //统计时间段内允许的最大请求数量
}
}
],
"GlobalConfiguration": {
"ServiceDiscoveryProvider": {
"Host": "122.45.216.26", //Nginx For Consul IP
"Port": 21080, //Nginx For Consul Port
"Type": "Consul" //由Consul提供服务发现, 每次请求去consul
}
}
}
////*****************************单地址********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "47.95.2.2",
// "Port": 5726 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5726/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ]
// }
// ]
//}
////*****************************单地址全匹配********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/{url}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ]
// }
// ]
//}
////*****************************多地址多实例********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5726/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ]
// },
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5727 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5727/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ]
// },
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5728 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5728/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ]
// }
// ]
//}
//////MVC的路由规则是近水楼台先得月--
////*****************************路由冲突+带权匹配********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/{url}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "Priority": 0 //默认是0 加个1
// },
// {
// "DownstreamPathTemplate": "/api/users/get?id={id}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5727 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/api/users/get/{id}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "Priority": 1 //默认是0 加个1
// },
// {
// "DownstreamPathTemplate": "/api/users/{url}?id={id}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5728 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/api/users/{url}/{id}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "Priority": 2 //默认是0 加个1
// }
// ]
//}
////*****************************单地址多实例负载均衡********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "47.95.2.2",
// "Port": 5726
// }, //Ocelot负载均衡
// {
// "Host": "47.95.2.2",
// "Port": 5727
// },
// {
// "Host": "47.95.2.2",
// "Port": 5728
// }
// ],
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量 //冲突的还可以加权重Priority
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //轮询 //"LeastConnection" //最少连接数的服务器 "NoLoadBalance" //不负载均衡 //"CookieStickySessions" //会话粘滞 //
// }
// //"LoadBalancerOptions": {
// // "Type": "CookieStickySessions",
// // "Key": "ASP.NET_SessionId",
// // "Expiry": 1800000
// //}
// }
// ]
//}
//*****************************单地址多实例负载均衡+Consul********************************
//{
//"Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul服务名称
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
// }
// }
//],
//"GlobalConfiguration": {
// //"BaseUrl": "http://127.0.0.1:6299", //网关对外地址
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8086,
// "Type": "Consul" //由Consul提供服务发现, 每次请求去consul
// } //Ocelot没有支持配置多个Consul
//,"ServiceDiscoveryProvider": {
// "Host": "localhost",
// "Port": 8500,
// "Type": "PollConsul", //由Consul提供服务发现,
// "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// //"Token": "footoken"//需要ACL的话
//}
//}
//}
////*****************************Consul+缓存Cache********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul服务名称
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
// },
// "FileCacheOptions": {
// "TtlSeconds": 15, //Second
// "Region": "UserCache" //可以调用Api缓存清理
// }
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //由Consul提供服务发现, 每次请求去consul
// }
// //"ServiceDiscoveryProvider": {
// // "Host": "localhost",
// // "Port": 8500,
// // "Type": "PollConsul", //由Consul提供服务发现,
// // "PollingInterval": 1000 //轮询consul,频率毫秒--down掉是不知道的
// // //"Token": "footoken"//需要ACL的话
// //}
// }
//}
////*****************************超时+限流+熔断+降级+Consul+Polly********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/{url}", //服务地址--url变量
// "DownstreamScheme": "http",
// "UpstreamPathTemplate": "/T/{url}", //网关地址--url变量
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "UseServiceDiscovery": true,
// "ServiceName": "ZhaoxiService", //consul服务名称
// "LoadBalancerOptions": {
// "Type": "RoundRobin" //轮询 LeastConnection-最少连接数的服务器 NoLoadBalance不负载均衡
// },
// "RateLimitOptions": {
// "ClientWhitelist": [ "eleven", "seven" ], //白名单 ClientId 区分大小写
// "EnableRateLimiting": true,
// "Period": "5m", //1s, 5m, 1h, 1d
// "PeriodTimespan": 30, //多少秒之后客户端可以重试
// "Limit": 5 //统计时间段内允许的最大请求数量
// },
// "AuthenticationOptions": {
// "AuthenticationProviderKey": "UserGatewayKey",
// "AllowedScopes": []
// },
// "QoSOptions": {
// "ExceptionsAllowedBeforeBreaking": 3, //允许多少个异常请求
// "DurationOfBreak": 10000, // 熔断的时间,单位为ms
// "TimeoutValue": 2000 //单位ms 如果下游请求的处理时间超过多少则自如将请求设置为超时 默认90秒
// }
// //"FileCacheOptions": {
// // "TtlSeconds": 15,
// // "Region": "UserCache" //可以调用Api清理
// //}
// }
// ],
// "GlobalConfiguration": {
// "BaseUrl": "http://127.0.0.1:6299", //网关对外地址
// "ServiceDiscoveryProvider": {
// "Host": "47.95.2.2",
// "Port": 8089,
// "Type": "Consul" //由Consul提供服务发现
// },
// "RateLimitOptions": {
// "QuotaExceededMessage": "Too many requests, maybe later? 11", // 当请求过载被截断时返回的消息
// "HttpStatusCode": 666, // 当请求过载被截断时返回的http status
// //"ClientIdHeader": "client_id" // 用来识别客户端的请求头,默认是 ClientId
// }
// }
//}
////*****************************请求聚合Aggregator********************************
//{
// "Routes": [
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5726 //服务端口
// } //可以多个,自行负载均衡
// ],
// "UpstreamPathTemplate": "/T5726/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5726"
// },
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5727 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5727/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5727"
// },
// {
// "DownstreamPathTemplate": "/api/users/all",
// "DownstreamScheme": "http",
// "DownstreamHostAndPorts": [
// {
// "Host": "localhost",
// "Port": 5728 //服务端口
// }
// ],
// "UpstreamPathTemplate": "/T5728/users/all",
// "UpstreamHttpMethod": [ "Get", "Post" ],
// "key": "T5728"
// }
// ],
// "Aggregates": [
// {
// "RouteKeys": [
// "T5726",
// "T5727",
// "T5728"
// ],
// "UpstreamPathTemplate": "/UserAggregator", //如果某个404 是不影响返回,当成null
// "Aggregator": "CustomUserAggregator" //自定义聚合器
// }
// ]
//}