简体   繁体   English

在 AWS API Gateway 中使用自定义域 (apex)

[英]Use custom domain (apex) in AWS API Gateway

I would like to use a custom domain for an AWS API Gateway endpoint, this would allow me to use mydomain.com instead of https://xxxxxxxx.execute-api.eu-west-1.amazonaws.com/v1 .我想为 AWS API 网关端点使用自定义域,这将允许我使用mydomain.com而不是https://xxxxxxxx.execute-api.eu-west-1.amazonaws.com/v1

I managed to add the custom domain in API Gateway but now I need to set the DNS of the domain (this domain is NOT managed by Route53).我设法在 API Gateway 中添加了自定义域,但现在我需要设置域的 DNS(该域不是由 Route53 管理的)。

As far as I understand I should set an A record but I don't have any IP provided by the cloudfront distribution and it cannot be a CNAME because I want to bind a domain (apex) not a subdomain.据我所知,我应该设置 A 记录,但我没有 Cloudfront 分发提供的任何 IP,它不能是 CNAME,因为我想绑定域(顶点)而不是子域。

How could I set the domain, without transfering DNS management to Route 53 ?如何在不将 DNS 管理转移到 Route 53 的情况下设置域?

Thank you谢谢

This is not possible.这不可能。 Route 53 has special capabilities that allow you to alias the apex of a domain to another AWS resource, without using a CNAME record -- which is not valid at the apex of a domain. Route 53 具有特殊功能,允许您将域的顶点别名为另一个 AWS 资源,而无需使用 CNAME 记录 - 这在域的顶点无效。

You don't have to transfer your domain registration to Route 53 -- that's optional -- but you do have to create a hosted zone and configure your existing registrar to use the nameservers Route 53 assigns to your new hosted zone as your authoritative name servers.您不必将域注册转移到 Route 53 - 这是可选的 - 但您必须创建一个托管区域并配置您现有的注册商以使用 Route 53 分配给您的新托管区域的名称服务器作为您的权威名称服务器. Transferring the registration itself, or not, does not impact performance -- queries are neither slower nor faster when your domain name host and your registrar are two different providers or not.是否转移注册本身不会影响性能——当您的域名托管商和您的注册商是否是两个不同的提供商时,查询既不会变慢也不会变快。

I struggled quite a bit with the same problem and actually found a solution in this gist .我在同样的问题上挣扎了很多,实际上在这个 gist 中找到了解决方案。 As the gist suggests, you need to create a "Hosted Zone" in Route 53 (you don't need to transfer the domain or anything like that).正如要点所建议的,您需要在 Route 53 中创建一个“托管区域”(您不需要转移域或类似的东西)。

Once you create the zone, NS records are created in it.创建区域后,就会在其中创建 NS 记录。 They look something like this:它们看起来像这样:

ns-1208.awsdns-23.org.
ns-2016.awsdns-60.co.uk. 
ns-642.awsdns-16.net. 
ns-243.awsdns-30.com.

Just copy the NS (name server) records and replace the ones for your domain name at your DNS provider's control panel.只需复制 NS(名称服务器)记录并在您的 DNS 提供商的控制面板上替换您的域名的记录即可。 The NS records can be used to point DNS management from other domain registrar to AWS Route 53 NS 记录可用于将 DNS 管理从其他域注册商指向 AWS Route 53

This would take a while to update (around 1-2 days).这将需要一段时间才能更新(大约 1-2 天)。 You can go on and create an alias record in this hosted zone to point your apex domain to your API gateway (or a similar AWS service which doesn't provide a static IP).您可以继续在此托管区域中创建别名记录,以将您的顶点域指向您的 API 网关(或不提供静态 IP 的类似 AWS 服务)。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM