【发布时间】:2015-10-21 16:35:53
【问题描述】:
目标
- 通过 Cloudflare 运行 https://rapid.essbap.org。
- 这应该映射到https://ebcc-rrn.herokuapp.com(Rails 应用程序)
- 但是,我收到“重定向过多”页面,例如
- 之前已在其他 Heroku 应用上成功完成此操作,使用以下步骤
- 我错过了什么?
我做了什么
- 通过 Godaddy 购买
essbap.org。 - 已将 DNS 导入 Cloudflare。
- 在 Godaddy 插入 Cloudflare 名称服务器。
- 从 Godaddy 中删除了区域记录。
Cloudflare:
- 插入 CNAME 记录
rapid以指向ebcc-rrn.herokuapp.com - 在 Heroku 上:将自定义域
rapid.essbap.org添加到ebcc-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
Cloudflare 设置
刚刚添加:
跑步卷曲
当我对另一个我知道有效的 Heroku 自定义域应用程序运行 curl 时,它看起来像:
$ 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
ebcc-rrn.herokuapp.com 的类似行为(我们希望 rapid.essbap.org 成为其别名的 Herokuapp)。一个 301 然后 200。
但是当我对rapid.essbap.org 运行curl 时,我得到:
$ 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/
在第二种情况下,我们得到的是 301 而不是 200。我不确定为什么会生成 301。不会在 dev 或 ebcc-rrn.herokuapp.com 中发生。
我错过了什么?
【问题讨论】:
-
也看到我在这里发布的这个解决方案,可以帮助:stackoverflow.com/questions/43141495/…
标签: ruby-on-rails heroku dns cloudflare