如何在heroku应用程序中指向一个域 [英] How to point a domain at a heroku application
问题描述
虽然我已经在我的VPS上完成了这项工作,但我从来没有为heroku应用程序做过这件事,现在我必须为一家相当大的公司做这件事,所以我真的想要一个简单的关于如何这样做。
我已阅读这些说明,我对它们究竟意味着什么仍然有点不清楚。再次,如果我有更多时间,我会购买一些垃圾域并自己测试,但我没有时间在我身边,需要第一时间做对!
幸运的是,此时不需要SSL。
以下是我可以收集的内容,我需要做的是将url 指向www.foobaryfoobs .com
在我的应用程序中,运行在 warm-chamber-1882.herokuapp.com
。请改正我:
<1>我添加 www.foobaryfoobs.com
到包含应用程序的本地存储库。
我假设我通过导航到本地机器上的存储库并运行:
$ heroku域名:添加www.foobaryfoobs.com
-
这是如何工作的?它是否需要将某些配置文件更新到需要添加到存储库的位置,然后推送到heroku?
-
是否有任何警告或最佳实践?我应该添加哪些其他域名?
heroku域名:加* .foobaryfoobs.com
,例如? -
Heroku建议我们使用上述通配符域在这里。为什么?
$ hr
$ b2)登录创建<$的注册器c $ c> www.foobaryfoobs.com 并导航至其控制面板。
3)将域的CNAME记录更新为
warm-chamber-1882.herokuapp.com
-
我是大部分完成了?现在我只是等待吗?
-
-
为什么要关注这个问题:
- 对于一个nooby,请解释为什么这是必要的。
-
我不知道它在内部是如何工作的,但这个命令相当于在apache配置文件中添加
ServerName
,没有这个请求时<$ c $因为dns
但它会被转发到heroku,但是heroku无法确定你的应用程序。你会看到下面的图像。
这就是为什么他们需要你的域名,以便他们知道哪些应用属于哪个域名。他们也需要它来实现域优先目的。只要您允许用户访问Heroku子域,即
warm-chamber-1882.herokuapp.com
,代码中不需要进行任何更改。如果您不想让用户访问heroku子域名,您必须传递301
http状态,以便将其重定向到您的实际域名,即www.foobaryfoobs.com
。为此,您已将这添加到您的应用程序控制器中before_action:forward_to_domain_if_heroku_subdomain
private
def forward_to_domain_if_heroku_subdomain
if request.host =='warm-chamber-1882.herokuapp.com'
redirect_tohttp://www.foobaryfoobs.com,状态:301
结束
结束
-
如果您只想要使用
www.foobaryfoobs.com
作为你的域名,这个命令就足够了,即
heroku域名:添加www.foobaryfoobs.com
-
如果您想分配裸域
foobaryfoobs.com
那么你也必须运行
heroku域名:添加foobaryfoobs.com
-
如果您的应用程序使用子域名,如
子域名。 foobaryfoobs.com
那么你也必须运行
heroku域名:添加foobaryfoobs.com
- 是的。他们正在谈论
ALIAS
或ANAME
类型的记录。 (DNSimple提供它)。你必须关心它,因为从那个自定义记录类型很容易添加记录。它们就像预先定义的模板,例如ALIAS
是A
记录的模板。 How does this work? Does it update some configuration file somewhere that I need to add to the repository and then push up to heroku?
Are there any caveats or best practices here? What other domains should I add?
heroku domains:add *.foobaryfoobs.com
, for example?Heroku advises we use the above wildcard domain here. Why?
Am I done for the most part? Now do I just wait?
Is there no IP related stuff?
The domain has several dozen emails attached to it. As long as I don't touch the MX record, I should be fine?
What's a root domain? Why should I add it?
Why should I care that:
- For a nooby, please explain why this is necessary.
I dont know exactly how does it works internally but this command is equivalent of adding
ServerName
in apache config file, without this when request comes towww.foobaryfoobs.com
it will be forwarded to heroku because ofdns
but heroku fail to determine your app. You will see the below image.That's why they need your domain so they know which apps belongs to which domains. They also need it for domain precedence purpose. No changes are required in your code as long as you are okay to allow your user to access Heroku subdomain ie
warm-chamber-1882.herokuapp.com
. If you dont want user to access heroku subdomain you have to pass301
http status so it will be redirected to your actual domain i.ewww.foobaryfoobs.com
. For this you have add this in your application controllerbefore_action :forward_to_domain_if_heroku_subdomain private def forward_to_domain_if_heroku_subdomain if request.host == 'warm-chamber-1882.herokuapp.com' redirect_to "http://www.foobaryfoobs.com" , status: 301 end end
if you ONLY want to use
www.foobaryfoobs.com
as your domain, this command is suffice ieheroku domains:add www.foobaryfoobs.com
If you want to assign naked domain
foobaryfoobs.com
then you ALSO have to runheroku domains:add foobaryfoobs.com
If you application use subdomains like
subdomain.foobaryfoobs.com
then you also have to runheroku domains:add foobaryfoobs.com
- Yes. They are talking about
ALIAS
orANAME
type of records. (DNSimple provides it). You have to care it because from that custom-record-type it is easily to add record. They are like pre defined templates egALIAS
is template ofA
record.
该域名附有数十封电子邮件。只要我不碰MX记录,我应该没事? 什么是根域?为什么要添加它?
一些DNS主机提供了一种使用自定义记录类型在
区域顶点获得类似CNAME功能的方法。
blockquote>
4)更新域的FORWARD / URL记录,使
foobaryfoobs.com
指向www.foobaryfoobs.com
3结论性问题:
1)这是应该如何设置的:
应用程序:
warm-chamber-1882.herokuapp.com
<应该有以下配置(保存在一些奇怪的配置文件中,我不介意更多地了解它):域名:
www.foobaryfoobs.com
* .foobaryfoobs.com
域:
www.foobaryfoobs.com
应该有以下记录:
CNAME:warm-chamber-1882.herokuapp。 com
和
URL / FORWARD:foobaryfoobs.com目标:www.foobaryfoobs.com
MX:*只要我不碰它们,电子邮件仍然可以使用*
$ c $
确保您的DNS合作非常重要nfiguration与您添加到Heroku中的
自定义域名一致。特别是,如果您已将
配置为* .example.com的DNS以指向
example.herokuapp.com,请确保您还运行heroku域名:add
* .example.com 。否则,恶意的人可能会将baddomain.example.com添加到他们的Heroku应用程序,并接收您的应用程序的预计
的流量。
3)我应该如何调整具有SSL后端部分的网站的步骤?
> A。
$ heroku域名:添加www.foobaryfoobs.com
这个怎么用?它是否需要将某些配置文件更新到我需要添加到存储库的位置,然后推送到heroku?
这里有任何警告或最佳做法吗?我应该添加哪些其他域名? heroku域名:添加* .foobaryfoobs.com,例如?
2)登入注册商创建了www.foobaryfoobs.com并导航到其控制面板。
为了保持价值,您必须使用DNS管理工具。 b
$ b
3)将网域的CNAME记录更新为指向warm-chamber-1882.herokuapp.com
是的。
我大部分都完成了吗?现在,我只是等待吗?
是的,但也有其他的事情。
是否没有与IP相关的内容?
<是的,没有与IP相关的东西。
该域名附有数十封电子邮件。只要我不碰MX记录,我应该没问题?
是的。
什么是根域?我为什么要添加它?
如果您想接受来自
warm-chamber-1882.herokuapp.com $用户的请求c $ c>(不是
www。warm-chamber-1882.herokuapp.com
),那么你必须添加它。
为什么我应该关心这个问题:
某些DNS主机提供了一种在区域顶点使用类似CNAME的功能自定义记录类型。
4)更新域的FORWARD / URL记录,以便foobaryfoobs.com指向www.foobaryfoobs。对于一个nooby,请解释为什么这是必要的。
这是必要的,因为
www.foobaryfoobs.com
和foobaryfoobs.com
与<$ c $相同c> images.google.comnews.google
不同。www
没什么特别的,它只是一个子域。如果你不这样做,用户不能从foobaryfoobs.com
使用你的站点,但可以访问www.foobaryfoobs.com
。
B。
1)这是应该如何设置的?
是的,它是正确的。但是如果你想允许
foobaryfoobs.com
和www.foobaryfoobs.com
,你必须做下面的表格。如果您的应用没有使用除www
以外的任何子域,则不需要*。foobaryfoobs.com
记录。添加*。foobaryfoobs.com
。类型|名称|内容
---------------------------------------
ALIAS | foobaryfoobs.com | yoursite.herokuapp.com
CNAME | www.foobaryfoobs.com | yoursite.herokuapp.com
务必确保您的DNS配置同意与您添加到Heroku的自定义域名。特别是,如果您已将* .example.com的DNS配置为指向example.herokuapp.com,请确保您还运行heroku域:add * .example.com。否则,恶意的人可能会将baddomain.example.com添加到他们的Heroku应用程序中,并接收适用于您的应用程序的流量。
是。此外,你不必担心这一点。如果恶意用户可以在你的域名中设置子域名,那么他有能力去做大量的破坏:P。实际上,恶意用户无法访问您的DNS管理工具,因此您很安全。
While I've done this on my VPS, I've never done this for a heroku application, and now I have to do it for a fairly large company so I really want a simple list of bullet-points in how to do this.
I've read these instructions, and I'm still a little bit unclear on what exactly they mean. Again, if I had more time I'd buy some rubbishy domain and test it myself, but I don't have time on my side and need to get this right first time!
Thankfully, no SSL is required at this time.
Here's what I can gather I need to do to point the url
www.foobaryfoobs.com
at my application, running atwarm-chamber-1882.herokuapp.com
. Please correct me:
1) I add
www.foobaryfoobs.com
to the local repository containing the application.I presume I do this by navigating to the repository on my local machine and running:
$ heroku domains:add www.foobaryfoobs.com
2) Log into the registrar that created
www.foobaryfoobs.com
and navigate to its control panel.3) Update the domain's CNAME record to point at
warm-chamber-1882.herokuapp.com
Some DNS hosts provide a way to get CNAME-like functionality at the zone apex using a custom record type.
4) Update the domain's FORWARD / URL record so that
foobaryfoobs.com
points towww.foobaryfoobs.com
3 Conclusive Questions:
1) Is this how it should be set up?:
The app:
warm-chamber-1882.herokuapp.com
Should have the following configurations (saved in some weird config file that I wouldn't mind knowing more about about):
domains: www.foobaryfoobs.com *.foobaryfoobs.com
The domain:
www.foobaryfoobs.com
Should have the following records:
CNAME: warm-chamber-1882.herokuapp.com URL / FORWARD: foobaryfoobs.com target: www.foobaryfoobs.com MX: *as long as I don't touch them the emails will still work*
2) Am I covered against:
It’s important to make sure your DNS configuration agrees with the custom domains you’ve added to Heroku. In particular, if you have configured your DNS for *.example.com to point to example.herokuapp.com, be sure you also run heroku domains:add *.example.com. Otherwise, a malicious person could add baddomain.example.com to their Heroku app and receive traffic intended for your application.
3) How should I adjust the steps for a site that has an SSL backend section?
解决方案A.
$ heroku domains:add www.foobaryfoobs.com
How does this work? Does it update some configuration file somewhere that I need to add to the repository and then push up to heroku?
Are there any caveats or best practices here? What other domains should I add? heroku domains:add *.foobaryfoobs.com, for example?
2) Log into the registrar that created www.foobaryfoobs.com and navigate to its control panel.
To be precious, you have to do DNS management tool.
3) Update the domain's CNAME record to point at warm-chamber-1882.herokuapp.com
Yes.
Am I done for the most part? Now do I just wait?
Yes, but there are also other things.
Is there no IP related stuff?
Yes, there is no ip related stuff.
The domain has several dozen emails attached to it. As long as I don't touch the MX record, I should be fine?
Yes.
What's a root domain? Why should I add it?
if you want to accept requests from user at
warm-chamber-1882.herokuapp.com
(notwww. warm-chamber-1882.herokuapp.com
) then you have to add it.Why should I care that: Some DNS hosts provide a way to get CNAME-like functionality at the zone apex using a custom record type.
4) Update the domain's FORWARD / URL record so that foobaryfoobs.com points to www.foobaryfoobs.com
For a nooby, please explain why this is necessary.
It is necessary because
www.foobaryfoobs.com
andfoobaryfoobs.com
are different in a same way likeimages.google.com
andnews.google
differs.www
is nothing special it is just a subdomain. If you dont do this, user can't use your site fromfoobaryfoobs.com
but can accesswww.foobaryfoobs.com
.B.
1) Is this how it should be set up?
Yes, it is correct. But if you want to allow
foobaryfoobs.com
andwww.foobaryfoobs.com
, you have to do something like below table. You dont require*.foobaryfoobs.com
record if your app doesn't use any subdomain exceptwww
. It is bad practice actually to add*.foobaryfoobs.com
.Type | Name | Content --------------------------------------- ALIAS | foobaryfoobs.com | yoursite.herokuapp.com CNAME | www.foobaryfoobs.com | yoursite.herokuapp.com
It’s important to make sure your DNS configuration agrees with the custom domains you’ve added to Heroku. In particular, if you have configured your DNS for *.example.com to point to example.herokuapp.com, be sure you also run heroku domains:add *.example.com. Otherwise, a malicious person could add baddomain.example.com to their Heroku app and receive traffic intended for your application.
Yes. Moreover you dont have to worry about this. If the malicious user can set subdomain at your domain then he capable to do much destruction :P. Actually, malicious user can't access your DNS management tool so you're safe.
这篇关于如何在heroku应用程序中指向一个域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!