如何在heroku应用程序中指向一个域

编程入门 行业动态 更新时间:2024-10-27 20:37:00
本文介绍了如何在heroku应用程序中指向一个域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

虽然我已经在我的VPS上完成了这项工作,但我从来没有为heroku应用程序做过这件事,现在我必须为一家相当大的公司做这件事,所以我真的想要一个简单的关于如何这样做。

我已阅读这些说明,我对它们究竟意味着什么仍然有点不清楚。再次,如果我有更多时间,我会购买一些垃圾域并自己测试,但我没有时间在我身边,需要第一时间做对!

幸运的是,此时不需要SSL。

以下是我可以收集的内容,我需要做的是将url 指向www.foobaryfoobs 在我的应用程序中,运行在 warm-chamber-1882.herokuapp 。请改正我: 我添加 www.foobaryfoobs 到包含应用程序的本地存储库。

我假设我通过导航到本地机器上的存储库并运行:

$ heroku域名:添加www.foobaryfoobs

  • 这是如何工作的?它是否需要将某些配置文件更新到需要添加到存储库的位置,然后推送到heroku?

  • 是否有任何警告或最佳实践?我应该添加哪些其他域名? heroku域名:加* .foobaryfoobs ,例如?

  • Heroku建议我们使用上述通配符域在这里。为什么? $ hr $ b

    2)登录创建 www.foobaryfoobs 并导航至其控制面板。

    3)将域的CNAME记录更新为 warm-chamber-1882.herokuapp

    • 我是大部分完成了?现在我只是等待吗?

    • 该域名附有数十封电子邮件。只要我不碰MX记录,我应该没事? 什么是根域?为什么要添加它?

    • 为什么要关注这个问题:

    • 一些DNS主机提供了一种使用自定义记录类型在区域顶点获得类似CNAME功能的方法。

      blockquote>

      4)更新域的FORWARD / URL记录,使 foobaryfoobs 指向 www.foobaryfoobs

      • 对于一个nooby,请解释为什么这是必要的。
      3结论性问题: 1)这是应该如何设置的:

      应用程序:

      warm-chamber-1882.herokuapp

      <应该有以下配置(保存在一些奇怪的配置文件中,我不介意更多地了解它):

      域名: www.foobaryfoobs * .foobaryfoobs

      域:

      www.foobaryfoobs

      应该有以下记录:

      CNAME:warm-chamber-1882.herokuapp。 com URL / FORWARD:foobaryfoobs目标:www​​.foobaryfoobs MX:*只要我不碰它们,电子邮件仍然可以使用*

      确保您的DNS合作非常重要nfiguration与您添加到Heroku中的自定义域名一致。特别是,如果您已将配置为* .example的DNS以指向 example.herokuapp,请确保您还运行heroku域名:add * .example 。否则,恶意的人可能会将baddomain.example添加到他们的Heroku应用程序,并接收您的应用程序的预计的流量。

      3)我应该如何调整具有SSL后端部分的网站的步骤? > A。

      $ heroku域名:添加www.foobaryfoobs

      这个怎么用?它是否需要将某些配置文件更新到我需要添加到存储库的位置,然后推送到heroku?

    • 我不知道它在内部是如何工作的,但这个命令相当于在apache配置文件中添加 ServerName ,没有这个请求时<$ c $因为 dns 但它会被转发到heroku,但是heroku无法确定你的应用程序。你会看到下面的图像。

      这就是为什么他们需要你的域名,以便他们知道哪些应用属于哪个域名。他们也需要它来实现域优先目的。只要您允许用户访问Heroku子域,即 warm-chamber-1882.herokuapp ,代码中不需要进行任何更改。如果您不想让用户访问heroku子域名,您必须传递 301 http状态,以便将其重定向到您的实际域名,即 www.foobaryfoobs 。为此,您已将这添加到您的应用程序控制器中

      before_action:forward_to_domain_if_heroku_subdomain private def forward_to_domain_if_heroku_subdomain if request.host =='warm-chamber-1882.herokuapp' redirect_towww.foobaryfoobs,状态:301 结束结束

      这里有任何警告或最佳做法吗?我应该添加哪些其他域名? heroku域名:添加* .foobaryfoobs,例如?

    • 如果您只想要使用 www.foobaryfoobs 作为你的域名,这个命令就足够了,即

      heroku域名:添加www.foobaryfoobs

    • 如果您想分配裸域 foobaryfoobs 那么你也必须运行

      heroku域名:添加foobaryfoobs

    • 如果您的应用程序使用子域名,如子域名。 foob​​aryfoobs 那么你也必须运行

      heroku域名:添加foobaryfoobs

    • 2)登入注册商创建了www.foobaryfoobs并导航到其控制面板。

      为了保持价值,您必须使用DNS管理工具。 b $ b

      3)将网域的CNAME记录更新为指向warm-chamber-1882.herokuapp

      是的。

      我大部分都完成了吗?现在,我只是等待吗?

      是的,但也有其他的事情。

      是否没有与IP相关的内容?

      <是的,没有与IP相关的东西。

      该域名附有数十封电子邮件。只要我不碰MX记录,我应该没问题?

      是的。

      什么是根域?我为什么要添加它?

      如果您想接受来自 warm-chamber-1882.herokuapp (不是 www。warm-chamber-1882.herokuapp ),那么你必须添加它。

      为什么我应该关心这个问题:某些DNS主机提供了一种在区域顶点使用类似CNAME的功能自定义记录类型。

    • 是的。他们正在谈论 ALIAS 或 ANAME 类型的记录。 (DNSimple提供它)。你必须关心它,因为从那个自定义记录类型很容易添加记录。它们就像预先定义的模板,例如 ALIAS 是 A 记录的模板。
    • 4)更新域的FORWARD / URL记录,以便foobaryfoobs指向www.foobaryfoobs。对于一个nooby,请解释为什么这是必要的。

      这是必要的,因为 www.foobaryfoobs 和 foobaryfoobs 与 images.google 和 news.google 不同。 www 没什么特别的,它只是一个子域。如果你不这样做,用户不能从 foobaryfoobs 使用你的站点,但可以访问 www.foobaryfoobs 。 B。

      1)这是应该如何设置的?

      是的,它是正确的。但是如果你想允许 foobaryfoobs 和 www.foobaryfoobs ,你必须做下面的表格。如果您的应用没有使用除 www 以外的任何子域,则不需要 *。foobaryfoobs 记录。添加 *。foobaryfoobs 。

      类型|名称|内容 --------------------------------------- ALIAS | foob​​aryfoobs | yoursite.herokuapp CNAME | www.foobaryfoobs | yoursite.herokuapp

      务必确保您的DNS配置同意与您添加到Heroku的自定义域名。特别是,如果您已将* .example的DNS配置为指向example.herokuapp,请确保您还运行heroku域:add * .example。否则,恶意的人可能会将baddomain.example添加到他们的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 at my application, running at warm-chamber-1882.herokuapp. Please correct me:

      1) I add www.foobaryfoobs 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

      • 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, for example?

      • Heroku advises we use the above wildcard domain here. Why?

      2) Log into the registrar that created www.foobaryfoobs and navigate to its control panel.

      3) Update the domain's CNAME record to point at warm-chamber-1882.herokuapp

      • 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:

      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 points to www.foobaryfoobs

      • For a nooby, please explain why this is necessary.
      3 Conclusive Questions:

      1) Is this how it should be set up?:

      The app:

      warm-chamber-1882.herokuapp

      Should have the following configurations (saved in some weird config file that I wouldn't mind knowing more about about):

      domains: www.foobaryfoobs *.foobaryfoobs

      The domain:

      www.foobaryfoobs

      Should have the following records:

      CNAME: warm-chamber-1882.herokuapp URL / FORWARD: foobaryfoobs target: www.foobaryfoobs 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 to point to example.herokuapp, be sure you also run heroku domains:add *.example. Otherwise, a malicious person could add baddomain.example 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

      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?

    • 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 to www.foobaryfoobs it will be forwarded to heroku because of dns 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. If you dont want user to access heroku subdomain you have to pass 301 http status so it will be redirected to your actual domain i.e www.foobaryfoobs . For this you have add this in your application controller

      before_action :forward_to_domain_if_heroku_subdomain private def forward_to_domain_if_heroku_subdomain if request.host == 'warm-chamber-1882.herokuapp' redirect_to "www.foobaryfoobs" , status: 301 end end

    • Are there any caveats or best practices here? What other domains should I add? heroku domains:add *.foobaryfoobs, for example?

    • if you ONLY want to use www.foobaryfoobs as your domain, this command is suffice ie

      heroku domains:add www.foobaryfoobs

    • If you want to assign naked domain foobaryfoobs then you ALSO have to run

      heroku domains:add foobaryfoobs

    • If you application use subdomains like subdomain.foobaryfoobs then you also have to run

      heroku domains:add foobaryfoobs

    • 2) Log into the registrar that created www.foobaryfoobs 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

      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 (not www. warm-chamber-1882.herokuapp) 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.

    • Yes. They are talking about ALIAS or ANAME 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 eg ALIAS is template of A record.
    • 4) Update the domain's FORWARD / URL record so that foobaryfoobs points to www.foobaryfoobs

      For a nooby, please explain why this is necessary.

      It is necessary because www.foobaryfoobs and foobaryfoobs are different in a same way like images.google and news.google differs. www is nothing special it is just a subdomain. If you dont do this, user can't use your site from foobaryfoobs but can access www.foobaryfoobs.

      B.

      1) Is this how it should be set up?

      Yes, it is correct. But if you want to allow foobaryfoobs and www.foobaryfoobs, you have to do something like below table. You dont require *.foobaryfoobs record if your app doesn't use any subdomain except www. It is bad practice actually to add *.foobaryfoobs .

      Type | Name | Content --------------------------------------- ALIAS | foobaryfoobs | yoursite.herokuapp CNAME | www.foobaryfoobs | yoursite.herokuapp

      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 to point to example.herokuapp, be sure you also run heroku domains:add *.example. Otherwise, a malicious person could add baddomain.example 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应用程序中指向一个域

本文发布于:2023-08-05 17:08:38,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1306859.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   如何在   heroku

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!