Ocelot 招摇重定向问题

问题描述

我正在尝试在我的 Windows 2019 服务器上实现 Ocelot/Swagger/MMLib 和 .net 微服务。

一切正常,我可以使用 postman 通过 API 网关正确调用每个微服务,但我想显示 swagger 文档,因为 API 将被第三方使用。

如果我使用 IP 地址/端口号,则会显示正确的页面,其中包含我的微服务定义。但是,如果我将其重新路由到物理 url(例如 https://siteaddress.com/path/swagger.index.html),我会得到主要的 swagger 文档,但是“无法加载 API 定义”错误,然后是“未定义的获取错误 /swagger/docs/v1/test.

我的浏览器检查的网页给出了'Http Error 404.0 Not Found'。请求的网址是“https://siteaddress.com:443/swagger/docs/v1/test”。

我的 ocelot.json 是:

{
  "Routes": [
    {
      "DownstreamPathTemplate": "/api/v1/TestSvc/{everything}","DownstreamScheme": "http","DownstreamHostAndPorts": [
        {
          "Host": "test.api","Port": "80"
        }
      ],"UpstreamPathTemplate": "/api/v1/TestSvc/{everything}","UpstreamHttpMethod": [ "POST" ],"SwaggerKey": "test"
    }
    ...
  ],"SwaggerEndPoints": [
    {
      "Key": "test","Config": [
        {
          "Name": "Test API","Version": "v1","Url": "http://test.api:80/swagger/v1/swagger.json"
        }
      ]
    }
    ...
  ]
}

我曾尝试更改 ocelot.json 和 startup.cs 中的路径。我在 MMLib 文档中没有看到关于这种情况的任何内容,这在部署这些站点时肯定很常见。

对下一步去哪里的建议表示赞赏。

Page with ipaddress and port number

Page with physical address and error message

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)