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找不到对应的服务对我的请求进行转发。各位大佬有空的话进来帮忙看看
我也遇到同样的问题,在global中添加了,也是不能实现转发。
我也是 解析出的ip 是node1 什么鬼
我看源码的逻辑就是如果有node信息,会使用node的name来作为下游url。因此需要借助dns服务器才行,我目前也在看是否可以通过一些操作来支持dns解析
也是 解析出的ip 是nodeName 怎么解决?
这个有答案了么?
你还需要在ocelot中配置下global,让ocelot能找到consul
– No_Rain 5年前https://github.com/ThreeMammals/Ocelot/pull/909
– daisen 4年前