ABP VNext 微服务搭建入门(5)-- 网关

网关

网关用于为应用程序提供单一入口点,而不是每个服务的不同地址。网关还用于速率限制,安全性,身份验证,负载平衡和更多要求。
该项目使用Ocelot库来构建API网关,分别有内部网关后端应用程序网关公共网站网关

Ocelot配置

appsettings.json

"ReRoutes": [
  {
    "DownstreamPathTemplate": "/api/identity/{everything}",
    "DownstreamScheme": "http",
    "DownstreamHostAndPorts": [
      {
        "Host": "localhost",
        "Port": 63568
      }
    ],
    "UpstreamPathTemplate": "/api/identity/{everything}",
    "UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
  },
  {
    "DownstreamPathTemplate": "/api/productManagement/{everything}",
    "DownstreamScheme": "http",
    "DownstreamHostAndPorts": [
      {
        "Host": "localhost",
        "Port": 60244
      }
    ],
    "UpstreamPathTemplate": "/api/productManagement/{everything}",
    "UpstreamHttpMethod": [ "Put", "Delete", "Get", "Post" ]
  }
],
"GlobalConfiguration": {
  "BaseUrl": "http://localhost:65115"
}

module

app.UseOcelot().Wait();
原文地址:https://www.cnblogs.com/zk-ljc/p/14167813.html