ruby-on-rails - Rails - 配置 DNS 以使用 Heroku (123-reg) 托管

标签 ruby-on-rails heroku dns

我想弄清楚如何在 上发布我的应用程序heroku .我的 DNS 是 123-reg。 123-reg 不为 heroku 部署提供任何支持,反之亦然。

我以前问过这个问题(在评论中被否决和 mock )
Rails, Heroku - configuring 123-reg domain for heroku

我再次询问,希望能找到有关如何使其工作的实质性帮助。

目前,当我尝试使用我的自定义域名呈现页面时,我收到一条错误消息:

无法访问此站点
www.mydomainname.com找不到 的服务器 DNS 地址。
尝试运行网络诊断。

DNS_PROBE_FINISHED_NXDOMAIN

当我在终端中尝试以下操作时,我得到以下响应:
host www.mycustomdomainname.com 

找不到主机 www.mycustomdomainname.com:3(NXDOMAIN)
host https://www.mycustomdomainname.com

主持人https://www.mycustomdomainname.com未找到:2(SERVFAIL)
dig www.mycustomdomainname.com cname +short

myherokualias.herokudns.com

heroku 域返回带有和不带有 www 前缀的 heroku 别名。

在我的 DNS 中,我有一个 CNAME 记录:

DNS 条目类型优先级 TTL 目的地/目标
www CNAME mycustomdomainname.herokudns.com。

除此之外,我的电子邮件帐户还有 MX 和 TXT 记录。

任何人都可以看到我需要做什么才能使用我的自定义域名呈现页面吗?

当我尝试:

curl -vI https://www.mycustomdomainname.com
* 重建 URL 到:https://www.mycustomdomainname.com/
* 无法解析主机:www.mycustomdomainname.com
* 关闭连接 0
curl: (6) 无法解析主机:www.mycustomdomainname.com

我迷失了尝试让它工作的事情

HEROKU 设置

通过检查我的 heroku Production Check,我可以看到我有以下问题:
FAILED DNS configuration
Your DNS is not configured correctly. Your domain "mycustomdomain.com"'s ALIAS or ANAME record should point to ancient-water-74339.herokuapp.com.

然而,它也说:
PASSED Heroku SSL

Heroku SSL 说明说:
Change your DNS for all domains on your app
Verify your DNS settings by running dig www.yourdomainname.com cname +short. If it returns www.yourdomainname.com.herokudns.com then you have set it up correctly. If you are using an ALIAS or ANAME record, you can verify that based on the DNS provider. For instance, DNSimple will return a TXT record showing how your domain’s ALIAS is set-up.
You should note that it may take up to 24 hours before your DNS is fully propagated globally.

对我来说,这意味着我应该用对“herokudns”的引用替换对“herokuapp”的引用。此外,我正在阅读这些说明以要求我将“ancient-water-74339”替换为“mycustomdomainname”。

我已经这样做了(按照我的理解),所以我 DNS 上的 CNAME 现在指向“mycustomdomainname”.herokudns.com。

heroku 生产检查表明这是不正确的。我应该有 2 个 CNAME 记录(一个使用 heroku alias.herokuapp),另一个使用 'mycustomdomainname'.heroku DNS ?

我尝试将 LetsEncrypt_plugin gem 用于 rails。我无法验证该配置中是否存在错误,因为该 gem 不提供对 heroku 的支持。

谁能看到我应该怎么做才能摆脱这种配置 hell ?

带有 SSL 的 DNS 的 heroku 生产检查说明提供了配置 SSL 端点的说明。 SSL Endpoint 说明说它们仅适用于旧客户端(我不知道什么是旧客户端),但该页面建议改用 Heroku SSL。这些说明说在应用程序名称的末尾使用“herokudns.com”。

我似乎无法让这些说明的任何组合起作用。

最佳答案

list

  • 在您的 DNS 提供商上,确保您的 CNAME 记录设置正确:
    Host: *
    Points To: yourapp.herokussl.com
    

    How to add a CNAME record in 123-reg
  • 在 Heroku 上,转到“资源”并确保您拥有 SSL add-on安装。
  • 在 Heroku 上,转到“设置/域和证书”并确保您正确设置了自定义域:
    Domain Name: *.yourdomain.com
    DNS Target: yourapp.herokussl.com
    

    请注意 herokuapp.com 和 herokussl.com 上的 URL 可能不同。如果您使用的是 SSL 证书,则必须使用后者。

  • 常见问题
  • 使用 heroku 工具带确保您的 SSL 证书仍然受信任
    heroku certs:info --app yourapp
    
  • 您的注册商和您的 DNS 提供商可能不同,这可能会导致您在错误的位置编辑 CNAME 记录。

    为确保您在正确的位置执行 whois在您的域中:
    whois yourdomain.com | grep 'Name Server'
    

    如果您的域实际上指向 123-reg,则输出应为:
    Name Server: ns1-123-reg.co.uk
    Name Server: ns2-123-reg.co.uk
    

    如果输出是其他内容,那么您可能应该在其他地方设置 CNAME 记录。

  • 希望这有帮助 <3

    关于ruby-on-rails - Rails - 配置 DNS 以使用 Heroku (123-reg) 托管,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40142742/

    相关文章:

    css - Devise 不加载自定义 CSS

    ruby-on-rails - Rails 3 按日期计算记录

    django - Postgres EXPLAIN ANALYZE 成本估算行数大大高于实际行数。没有吸尘?

    Scala Play 2.2 应用程序在 Heroku 中部署后崩溃 : target/start No such file or directory

    ssl - 在哪里安装SSL?

    nginx - proxy_pass 不使用/etc/hosts 解析 DNS

    dns - Plesk DNS,将子域定向到自定义 URL?

    ruby-on-rails - Unicorn PID 在初始部署时已经过时

    ruby-on-rails - OmniAuth:Builder#call 在每个请求上被调用

    ruby-on-rails - 使用 Action Cable 将 Ruby on Rails 应用程序部署到 Heroku(Puma 端口监听)