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

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

问题描述

我有一个域,example.com,我想用于我的rails-app驻留在example.herokuapp.com,我很困惑如何去做这个。

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或
ANAME)。

"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.com的示例CNAME的例子意味着Heroku可以并且可能移动example.herokuapp.com所指向的位置,但是您不需要更新任何内容,因为您使用CNAME记录,而Heroku是管理example.herokuapp.com指向哪里(可以是另一个CNAME或IP地址)。 CNAME记录的问题是它们不能指向IP地址,对于www.example.com而言,这是一个很好的例子,但是与example.com有关。 Heroku以前发布了用于裸机域的IP地址,但是遇到DDOS攻击时出现问题,并且无法用新的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还支持重定向记录,因此您可以将www.example.com重定向到DNS提供商级别的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天全站免登陆