小编cor*_*ser的帖子

Ocelot 无法匹配上游路径的路由配置

你好,现在我正在尝试使用 Ocelot gateway 通常我在不同的服务器上有一个 api,例如

https://server_domain.net/kpiDashboardApi
Run Code Online (Sandbox Code Playgroud)

没有网关,如果我直接发送请求到下面的链接,它可以工作

https://server_domain.net/kpiDashboardApi/Report/DocumentTypeCounts
Run Code Online (Sandbox Code Playgroud)

我想从本地的 Ocelot 到达此 api 中的端点,我使用下面的配置 json

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/kpiDashboardApi/Report/DocumentTypeCounts",
      "DownstreamScheme": "https",
      "DownstreamHostAndPorts": [
        {
          "Host": "https://server_domain.net/kpiDashboardApi",
          "Port": 443
        }
      ],
      "UpstreamPathTemplate": "/Report/DocumentTypeCounts",
      "UpstreamHttpMethod": [ "Post" ]
    }
  ],
  "GlobalConfiguration": {
    "BaseUrl": "https://localhost:5001"
  }
}
Run Code Online (Sandbox Code Playgroud)

当你发送请求到https://localhost:5001/kpiDashboardApi/Report/DocumentTypeCounts

它返回 404 并在下面的控制台中返回错误

警告:Ocelot.DownstreamRouteFinder.Middleware.DownstreamRouteFinderMiddleware[0] requestId:0HMFMPNHV9VHO:00000001,previousRequestId:没有先前的请求 id,消息:DownstreamRouteFinderMiddleware 设置管道错误。IDownstreamRouteFinder 返回错误代码:UnableToFindDownstreamRouteError 消息:无法匹配上游路径的路由配置:/kpiDashboardApi/Report/DocumentTypeCounts,动词:POST。警告:Ocelot.Responder.Middleware.ResponderMiddleware[0] requestId:0HMFMPNHV9VHO:00000001,previousRequestId:没有以前的请求 id,消息:错误代码:UnableToFindDownstreamRouteError 消息:无法匹配上游路径的路由配置:/kpiDashboardApi/Report/DocumentTypeCounts,动词: 邮政。在 ResponderMiddleware 中发现错误。设置错误响应请求路径:/kpiDashboardApi/Report/DocumentTypeCounts,请求方式:POST

我找不到缺失的部分。我的错误在哪里?

提前致谢

c# .net-core ocelot

5
推荐指数
1
解决办法
5700
查看次数

标签 统计

.net-core ×1

c# ×1

ocelot ×1