Heroku 上的自定义根域 [英] Custom root domain on Heroku

查看:17
本文介绍了Heroku 上的自定义根域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个域example.com,我想将它用于位于example.herokuapp.com的rails-app,但我很困惑如何去做.

I have a domain, example.com, that I want to use for my rails-app that resides at example.herokuapp.com and I'm pretty confused how to go about to do this.

Heroku 说

区域顶点域(又名裸"、裸"或根"域),例如,example.com,不支持使用传统的 DNS A 记录Heroku."然后他们继续解释解决方法(使用 ALIAS 或姓名).

"Zone apex domains (aka "naked", "bare" or "root" domains), e.g., example.com, using conventional DNS A-records are not supported on Heroku." And then they go on explaining workarounds (using ALIAS or ANAME).

我已经花了一个小时来阅读这个主题(这里是 SO 和其他地方),但仍然没有解决这个问题.

I have spent a good hour reading up on the subject (here on SO and elsewhere) but still don't get my head around this.

是否有其他方法或解释来说明如何为假人"完成此操作?

Are there any alternative ways or explanations on how to acomplish this for "a dummy"?

推荐答案

我会尝试一下,因为这是一个常见问题.

I'll take a stab at this as it's a frequent question.

好的,假设您有一个域 example.com 并且您想使用 www.example.com 来托管您的网站.在传统托管中,您可能有一个已分配 IP 地址的虚拟服务器,在这种情况下,您将使用主机记录,也称为 DNS 控制面板中的 A 记录将 www.example.com 映射到 IP 地址.在这种情况下,由于您现在已将 www.example.com 设置为固定 IP 地址,如果该 IP 地址发生变化,您将需要自行更新 DNS.

Ok, so assuming you have a domain example.com and you want to use www.example.com to host your site. In traditional hosting you'd probably have a virtual server which has been assigned an IP address, in this case you would use a host record, otherwise known as an A record in DNS control panels to map www.example.com to the IP address. In this case, since you have now set www.example.com to a fixed IP address should that IP address ever change you will need to update your DNS yourself.

此外,对于传统托管,您可以将 example.com 设置为相同的 IP 地址,以便 www.example.com 和 example.com 可用于裸域.

Also, with traditional hosting you could have example.com set to the same IP address so www.example.com and example.com would work for naked domains.

好的,那么什么是 CNAME 记录.CNAME 记录而不是映射到 IP 地址将记录映射到另一个 DNS 条目.因此,www.example CNAME 到 example.herokuapp.com 意味着 Heroku 可以并且可能会移动 example.herokuapp.com 指向的位置,但您不必更新任何内容,因为您使用的是 CNAME 记录,而 Heroku 是管理 example.herokuapp.com 指向的位置(可以并且可能是另一个 CNAME 或 IP 地址).CNAME 记录的问题在于它们不能指向 IP 地址,这对于 www.example.com 来说很好,但对于 example.com 来说是个问题.Heroku 之前发布了用于裸域的 IP 地址,但是当他们遭受 DDOS 攻击并且无法用新 IP 替换这些 IP 时,问题随之而来,因为它们是已发布的 IP 地址.对于新的欧盟地区,Heroku 不会发布用于裸域的 IP 地址.

Ok, so what's a CNAME record. A CNAME record rather than mapping to an IP address maps the record to another DNS entry. So, www.example CNAME'd to example.herokuapp.com means that Heroku can and may move where example.herokuapp.com is pointing at but you don't have to update anything as you're using an CNAME record and Heroku are managing where example.herokuapp.com is pointing (which can and may be another CNAME or an IP address). The problem with CNAME records is that they CANNOT point to an IP address, which is fine for www.example.com but a problem with example.com. Heroku previously published IP addresses to be used for naked domains but problems ensued when they suffered DDOS attacks and couldn't replace those IPs with new ones as they were published IP addresses. For the new EU region, Heroku ARE NOT publishing IP addresses for use with naked domains.

几个 DNS 提供商(我知道是 DNSsimple)所做的是将他们自己的 ALIAS 记录添加到他们的 DNS 服务器,以允许您在裸域中使用 CNAME,这样 www.example.com 和 example.com 都可以像现在一样工作由 Heroku 支持.如果您的 DNS 提供商不支持 ALIAS 记录,那么值得将域移至支持它的 DNS 提供商.DNSsimple 还支持重定向记录,因此您可以在 DNS 提供商级别而不是在您的应用程序层将 www.example.com 重定向到 example.com.

What several DNS providers (DNSsimple I know is one) have done is add their own ALIAS records to their DNS servers to allow you to use CNAME's with naked domains so both www.example.com and example.com will work as now supported by Heroku. If you DNS provider does not support ALIAS records then it's worth moving the domain to a DNS provider that does support it. DNSsimple also supports redirect records so you can have www.example.com redirect to example.com at the DNS provider level and not at your application layer.

这篇关于Heroku 上的自定义根域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆