使用Cloudflare的免费Universal SSL,尝试在Heroku上完全免费获取SSL。
阅读此文章:http://mikecoutermarsh.com/adding-ssl-to-heroku-with-cloudflare/,其中似乎暗示现在Cloudflare提供了免费的SSL。
我采取的步骤:
- 使用Cloudflare(免费帐户)设置我的DNS
- 将我的域名转发到我的herokuapp (CNAME example-app.com -> example-app.herokuapp.com)
- 将Cloudflare SSL选项设置为“Full SSL”
- 将我的域名添加到我的heroku应用程序
使用此express中间件强制使用 https:
app.use(function(req, res, next) { if (req.headers['x-forwarded-proto'] != 'https') { res.redirect('https://' + req.headers.host + req.path); } else { return next(); } });
Heroku域名http://example-app.herokuapp.com正常工作,并重定向到https://example-app.herokuapp.com,绿色锁定一切。
http://example-app.com和https://example-app.com都无法使用。浏览器标签图标只是不停地旋转而且永远不会解决。有什么办法可以让它工作吗?这真的可能吗?
*更新
看起来这实际上是可能的。来自CloudFlare支持的消息:
Hi Bill,
从根本上讲,只要“源”支持SSL连接,您就可以在CloudFlare中使用完整SSL。
Simon
CloudFlare今天发布了这篇博客文章:https://blog.cloudflare.com/universal-ssl-be-just-a-bit-more-patient/
我的网站已经开始解析,但出现了一个“您的连接不是私人连接”的消息,就像博客文章中的“您可能会看到的错误”部分一样。此外,在我的CloudFlare设置中有一个“SSL发出”警报,所以我想一旦发出它可能就会起作用。我会继续通知大家。