Rails Heroku SSL https:// 重定向

4
我有一个使用Rails 5开发的应用程序,并添加了Heroku的SSL证书。www.example.com和example.com都可以正常工作,但是当我在我的网站前加上"https://"时,它就无法工作,而"http://"可以正常工作。
我使用Namecheap.com来管理我的DNS。如何让“https://example.com”指向我的Heroku应用程序?

如果您使用Heroku托管服务器,如果使用herokuapp子域名,则默认打开https端口。但是对于自定义域,您需要购买SSL证书!https://devcenter.heroku.com/articles/ssl-endpoint第二件事实际上不是重定向的事情,您需要做的就是配置CNAME指向您的Heroku应用程序!https://devcenter.heroku.com/articles/custom-domains - Hieu Pham
1个回答

11
你需要做的是:
你需要在你的heroku应用程序中添加SSL Endpoint插件。
它将为你的heroku应用程序提供一个EndPoint URL。

https://devcenter.heroku.com/articles/ssl-endpoint

您需要添加来自第三方供应商的配置了SSL证书。

然后,您可以使用来自 SSL Endpoint 插件的给定 EndPoint URL 添加 CNAME 记录。

请确保将其添加到 config/environments/production.rb 中。

config.force_ssl = true

那时它会起作用。


我已经购买并集成了Heroku的SSL证书。我正在使用新的Heroku SSL集成,https://devcenter.heroku.com/articles/ssl,而不是Endpoint SSL。如果我将根域名的CNAME设置为myapp.herokudns.com,则会失去向根域名添加MX记录的能力,因此无法接受我的域名的电子邮件。 - An Le

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接