公共 Route53 CNAME 记录到私有 API 网关

问题描述 投票:0回答:1

背景

我有一个连接到 VPC 端点的私有 API 网关,我 NOT 使用私有 DNS。因此,

https://${aws_api_gateway_rest_api.this.id}-${aws_vpc_endpoint.this.id}.execute-api.${var.region}.amazonaws.com/${var.stage}/${var.path}
形式的 url 是 publicly resolvable per Invoke Private API via VPC Endpoint with Route 53 Alias。这是我组织的其他内部客户端使用的端点,这些客户端来自我们的私有多云网络。

我可以通过以下方式从我的专用网络成功调用此 URL:

curl -v -X POST https://${aws_api_gateway_rest_api.this.id}-${aws_vpc_endpoint.this.id}.execute-api.${var.region}.amazonaws.com/${var.stage}/${var.path}
.

必要的设计

每当 api 网关 id 或 vpc 端点 id 更改时,此 URL 将更改。我需要一个 static url,我可以提供给内部客户,它将 never change.

尝试的解决方案

我在名为

endpoint.sub.domain.com
的公共托管区域中创建名为
sub.domain.com
的 route53 CNAME 记录,并将其指向
${aws_api_gateway_rest_api.this.id}-${aws_vpc_endpoint.this.id}.execute-api.${var.region}.amazonaws.com
作为静态“代理”,始终指向私有 API 网关的底层公共可解析 DNS 记录.

发生了什么事

我像上一个一样卷曲它并收到:

curl -v -X POST https://endoint.sub.domain.com/<stage>/<path>
但有 TLS 问题:

Server certificate:
*  subject: CN=*.execute-api.us-east-1.amazonaws.com
*  start date: Sep 19 00:00:00 2022 GMT
*  expire date: Sep 16 23:59:59 2023 GMT
*  subjectAltName does not match endpoint.sub.domain.com
* SSL: no alternative certificate subject name matches target host name 'endpoint.sub.domain.com'
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, close notify (256):
curl: (60) SSL: no alternative certificate subject name matches target host name 'airport-mock-endpoint.npd.nortonalto.com'
More details here: https://curl.se/docs/sslcerts.html

curl failed to verify the legitimacy of the server and therefore could not
establish a secure connection to it. To learn more about this situation and
how to fix it, please visit the web page mentioned above.

尝试与

--insecure
相同只是为了看看:
curl --insecure -v -X POST https://endoint.sub.domain.com/<stage>/<path>

并收到
{"message”:”Forbidden”}
.

同样尝试,这次指定 api 网关 id:

curl --insecure -v -X POST https://endoint.sub.domain.com/<stage>/<path> -H "x-apigw-api-id:5xxxxxxf"

并收到:
{"message":"Missing Authentication Token"}

尝试相同,这次将 CNAME 记录(原始 url)的目标指定为Host

curl --insecure -v -X POST https://endoint.sub.domain.com/<stage>/<path> -H "Host: {api-gateway-id}-{vpc-endpoint-id}.execute-api.us-east-2.amazonaws.com"

并收到:
成功!

问题

客户端必须能够调用此 API 而无需传入主机标头 并且 使用与原始端点提供的相同的安全 TLS。如何实现?


可能的解决方案

1。让服务器 302 重定向请求

  • 不知道这样能不能解决所有问题
  • 不优雅,因为我想纯粹从 DNS 完成这个

2。配置涉及 Cloud Front 的东西?

3。一些 Route 53 / API 网关 DNS 配置?

4。在我的 VPC 中启用私有 DNS

amazon-web-services networking aws-api-gateway amazon-route53 amazon-vpc
1个回答
0
投票

Api 网关将仅通过称为“自定义域”的功能为您的“静态”域证书提供服务,私有 api 网关不支持该功能。请参阅此 aws 文档中的第一个蓝色注释框:https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html

我知道的唯一可用解决方案在 aws github 中描述https://github.com/aws-samples/serverless-samples/tree/main/apigw-private-custom-domain-name

此解决方案通过在您的私有 api 网关前创建网络负载均衡器来解决此限制,该网关可以配置为使用您的“静态”域证书。

© www.soinside.com 2019 - 2024. All rights reserved.