简体   繁体   English

来自不同区域的多个 API 具有相同自定义名称和不同基本路径的网关

[英]Multiple API Gateways from different regions with the same Custom Name and different base path

I have 10 different APIs across two AWS regions (us-east-1, ca-central-1).我在两个 AWS 区域(us-east-1、ca-central-1)有 10 个不同的 API。 Using base path mapping, us-east-1.example.com is serving 5 APIs in US and ca-central-1.example.com is serving the other 5 APIs (API Gateway).使用基本路径映射,us-east-1.example.com 为美国的 5 个 API 提供服务,ca-central-1.example.com 为其他 5 个 API(API 网关)提供服务。 Although the backend is running the same code, it was part of the requirement from clients.尽管后端运行相同的代码,但这是客户要求的一部分。 Our clients are public universities and they want to have their own servers in their own country.我们的客户是公立大学,他们希望在自己的国家拥有自己的服务器。 For example, the current setup is using Custom Name & base path from API Gateway.例如,当前设置使用来自 API 网关的自定义名称和基本路径。

American universities:美国大学:

us-east-1.example.com/harvard
us-east-1.example.com/stanford
us-east-1.example.com/mit

Canadian universities:加拿大大学:

ca-central-1.example.com/ubc
ca-central-1.example.com/bcit
ca-central-1.example.com/waterloo

Is there a way to combine them into a single custom domain using Route 53 like the following?有没有办法像下面这样使用 Route 53 将它们组合成一个自定义域?

api.example.com/harvard
api.example.com/ubc

I just talked to an AWS Professional and was told this is not a possible architecture.我刚刚与 AWS 专业人士交谈,被告知这不是一种可能的架构。

You can definitely use CloudFront for this and you can use Route53 to make it available under your custom domain.您绝对可以为此使用 CloudFront,并且可以使用 Route53 使其在您的自定义域下可用。 Add each university as an origin and add a cache behavior for each of them with the path pattern of the university's name and the target the corresponding origin.添加每所大学作为原点,并使用大学名称的路径模式为每个大学添加缓存行为,并以相应的原点为目标。

You'll have origins:你会有起源:

  • harvard => us-east-1.example.com哈佛 => us-east-1.example.com
  • stanford => us-east-1.example.com斯坦福 => us-east-1.example.com
  • ubc => ca-central-1.example.com ubc => ca-central-1.example.com
  • ... ...

and cache behaviors:和缓存行为:

  • /harvard => harvard (origin) /哈佛 => 哈佛(起源)
  • /stanford => stanford /斯坦福 => 斯坦福
  • /ubc => ubc /ubc => ubc

When a request comes in, CloudFront checks the path pattern and routes the response to the correct API Gateway endpoint.当收到请求时,CloudFront 检查路径模式并将响应路由到正确的 API 网关端点。 The downside is that you need to modify the CloudFront distribution when there is a new university you want to route to.不利之处在于,当您想要路由到一所新大学时,您需要修改 CloudFront 分配。 I've written some articles about how routing in CloudFront works.我写了一些关于 CloudFront 中的路由如何工作的文章。

To host it under your own domain name, you need to use ACM to request a certificate for that domain, then add an Alternate Domain Name to the CloudFront distribution, and finally add an A (and AAAA) record to the Route53 hosted zone pointing to the distribution.要在您自己的域名下托管它,您需要使用 ACM 为该域申请证书,然后将备用域名添加到 CloudFront 分配,最后将 A(和 AAAA)记录添加到 Route53 托管区域指向分布。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从不同的 AWS 区域为我的胶水作业检索数据? - How to retrieve data from different AWS regions for my glue job? 将 GraphQL 请求路由到不同区域的 API,服务不同的内容但使用相同的模式 - Route GraphQL requests to APIs in different regions serving different content but using same schema 如何在不同区域的数据集之间移动数据? - how to move data between datasets in different regions? Blob 存储可以在不同区域之间共享吗? - Can blob storage be shared between different regions? 如何使用内部 IP 在同一 VPC 但不同的 su.net(区域)内通信 2 个实例 - how to communicate 2 instances inside the same VPC but different subnets (regions) using internal IP 如何指示 CloudFront 使用来自两个不同区域(一个活动区域和一个 DR 区域)的两个 ALB - How to point CloudFront to use two ALB's from two different regions (one active region and one DR region) 不同区域中的虚拟机无法访问第三方区域中的存储 - VMs in different regions can't access a storage held in a third region 如何将 Springboot 应用程序连接到 Azure SB,具有跨不同主题的多个订阅(同名) - How to connect a Springboot app to an Azure SB with multiple subscriptions (with same name) across different topics GCP - 同一网站和数据库的多个区域 - GCP - Multiple regions for same website and database 我可以使用 Firestore 检索具有相同名称的不同集合中相同子集合的文档吗? - Can I retrieve documents of same subcollection in different collections with the same name, using Firestore?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM