Cloudflare上的Heroku自定义域:重定向太多

Dan*_*May 8 dns ruby-on-rails heroku cloudflare

目标

在此输入图像描述

  • 之前在其他Heroku应用程序上成功完成此操作,使用以下步骤
  • 我错过了什么?

我做了什么

  • essbap.org通过Godaddy 购买.
  • 导入DNS到Cloudflare.
  • 在Godaddy插入Cloudflare名称服务器.
  • 从Godaddy删除了区域记录.

CloudFlare的:

  • 插入的CNAME记录rapid指向ebcc-rrn.herokuapp.com
  • 在Heroku:添加自定义域rapid.essbap.orgebcc-rrn.herokuapp.com

Heroku的:

heroku domains:add rapid.essbap.org

=== ebcc-rrn Heroku Domain
ebcc-rrn.herokuapp.com

=== ebcc-rrn Custom Domains
Domain Name       DNS Target
----------------  ----------------------
rapid.essbap.org  ebcc-rrn.herokuapp.com 

$ host rapid.essbap.org 
rapid.essbap.org has address 104.27.162.137 
rapid.essbap.org has address 104.27.163.137
Run Code Online (Sandbox Code Playgroud)

Cloudflare设置

在此输入图像描述

刚刚添加:

跑步卷曲

当我curl与另一个我认识有效的Heroku自定义域应用程序运行时,它看起来像:

$ curl -I some.custom_app.com
HTTP/1.1 301 Moved Permanently
Location: https://some.custom_app.com/

# since I'm using force_ssl on Rails, we expect to be directed to https://

$ curl -I https://some.custom_app.com/
HTTP/1.1 200 OK
Run Code Online (Sandbox Code Playgroud)

类似的行为ebcc-rrn.herokuapp.com(Herokuapp我们希望rapid.essbap.org成为别名).一个301然后200.

但是当我curl反对时rapid.essbap.org,我得到:

$ curl -I rapid.essbap.org
HTTP/1.1 301 Moved Permanently
Location: https://rapid.essbap.org/

# since I'm using force_ssl on Rails, we expect to be directed to https://

$ curl -I https://rapid.essbap.org
HTTP/1.1 301 Moved Permanently
Location: https://rapid.essbap.org/
Run Code Online (Sandbox Code Playgroud)

在第二种情况下,我们得到301而不是200.我不确定为什么要生成301.不会发生在开发或与ebcc-rrn.herokuapp.com.

我错过了什么?

chr*_*sby 6

我的情况是将Crypto-> SSL 设置Flexible为有效Full


ste*_*son 5

我最近在一个网站上遇到了同样的问题,也使用了 Heroku 和 Cloudflare 以及 SSL。

在我们的案例中,解决方案是我们必须将 Cloudflare 中的 Crypto > SSL 下的 SSL 选项设置为Flexible. 我们将其设置为Full,这导致该站点尝试使用 CloudFlare 的 SSL 证书。它不适用于 SSL 选项设置为Off.

  • 对我来说正好相反——我在 Heroku 站点上设置了 SSL,并且使用 Cloudlfare SSL 不断收到过多的重定向,如“Off”或“Flexible”。将它设置为“完整(严格)”对我有用,因为服务器上已经存在 SSL。 (3认同)

Dan*_*May 3

不幸的是,没有决定性的解决方案(但非常感谢 Heroku 的技术帮助)。

设法通过回滚并重试来解决问题:

  • 将 DNS 传输回 Godaddy
  • 从 Cloudflare 擦除域名
  • 确保 Godaddy 的功能
  • 在 Cloudflare 上创建域
  • 再次转移到 Cloudflare

现在一切都按计划进行。