首页 新闻 赞助 找找看

ocelot+consul的配置问题

0
悬赏园豆:80 [待解决问题]

1.在使用
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddOcelot(Configuration)
.AddConsul()
.AddConfigStoredInConsul()
.AddPolly();
}
该方法一旦使用AddConfigStoredInConsul(),启动项目之后页面就会报错500,内部服务错误。
2.我在consul中添加了一个name为TestApiServer的服务,并在ocelot中使用如下配置
{
"UseServiceDiscovery": true, // use Consul service discovery
"DownstreamPathTemplate": "/api/{url}",
"DownstreamScheme": "http",
"ServiceName": "TestApiServer",
"LoadBalancerOptions": {
"Type": "RoundRobin"
},
"UpstreamPathTemplate": "/TestApiServer/{url}",
"UpstreamHttpMethod": [ "Get", "Post" ],
"RateLimitOptions": {
"ClientWhitelist": [ "admin" ], // 白名单
"EnableRateLimiting": true, // 是否启用限流
"Period": "1m", // 统计时间段:1s, 5m, 1h, 1d
"PeriodTimespan": 15, // 多少秒之后客户端可以重试
"Limit": 10 // 在统计时间段内允许的最大请求数量
}
}
当我发起请求为http://192.168.22.122:8000/TestApiServer/values时,ocelot找不到对应的服务对我的请求进行转发。各位大佬有空的话进来帮忙看看

record_world的主页 record_world | 初学一级 | 园豆:154
提问于:2018-12-04 16:32

你还需要在ocelot中配置下global,让ocelot能找到consul

No_Rain 5年前
< >
分享
所有回答(4)
0

我也遇到同样的问题,在global中添加了,也是不能实现转发。

俊翳 | 园豆:204 (菜鸟二级) | 2019-06-23 17:30
0

我也是 解析出的ip 是node1 什么鬼

OpenLJW | 园豆:204 (菜鸟二级) | 2019-06-28 13:31
0

我看源码的逻辑就是如果有node信息,会使用node的name来作为下游url。因此需要借助dns服务器才行,我目前也在看是否可以通过一些操作来支持dns解析

daisen | 园豆:202 (菜鸟二级) | 2019-09-18 09:01
0

也是 解析出的ip 是nodeName 怎么解决?

MUYIgUAN | 园豆:204 (菜鸟二级) | 2019-12-31 11:07

这个有答案了么?

支持(0) 反对(0) xboo | 园豆:200 (初学一级) | 2020-03-13 18:30
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册