ocelot+consul的配置问题

HaiLan_xu HaiLan_xu 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
1.在使用
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
services.AddOcelot(Configuration)
.AddConsul()
.AddConfigStoredInConsul()
.AddPolly();
}
该方法一旦使用AddConfigStoredInConsul(),启动项目之后页面就会报错500,内部服务错误。如果不使用该方法并且reroute的下游服务使用ip和端口的明文配置,那么可以正常请求
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找不到对应的服务对我的请求进行转发。各位大佬有空的话进来帮忙看看
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
HaiLan_xu
.NET技术其他语言 1,979 成员 12,447 内容