0

我有一些 api,它们前面有一个 api 网关。它恰好是 Ocelot,这是我在本地环境中的配置:

  "ReRoutes": [
    {
      "DownstreamPathTemplate": "/{everything}",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost",
          "Port": 5000
        }
      ],
      "UpstreamPathTemplate": "/api1/{everything}",
      "UpstreamHttpMethod": [ "Get", "Post" ]
    },

该 api 作为 Kestrel 运行。没有码头工人。但是在生产系统上,它应该安装在 IIS 中

问题是这样的:在我的 locan 环境中,所有 apis,在 localhost 上运行的 api 网关,nad 都有一个端口。但是在服务器上,它们被安装为网站,以及网站内的应用程序。所以如果网站的地址是xyz.com,那么api1的地址就是xyz.com/api1。它是可用的。我不希望它可用,只能通过 api 网关。第一个问题是,如何仅通过 api 网关访问。

第二个问题是,它不起作用。这是我在服务器上的配置:

  "ReRoutes": [
    {
      "DownstreamPathTemplate": "/Api1Api/{everything}",
      "DownstreamScheme": "http",
      "DownstreamHostAndPorts": [
        {
          "Host": "localhost", <-- here I tried xyz.com too
          "Port": 80
        }
      ],
      "UpstreamPathTemplate": "/Api1/{everything}",
      "UpstreamHttpMethod": [ "Get", "Post" ]
    },

如果我去 xyz.com/Api1Api 它正在工作,但我不希望它工作,但如果我去 xyz.com/ApiGateway/Api1,它不工作,但我希望它从那里工作

4

0 回答 0