简体   繁体   English

具有自定义域的Heroku中的SSL

[英]SSL in Heroku with a custom domain

I'm using PointHQ as a DNS and hosting my domain on Heroku. 我使用PointHQ作为DNS,并将我的域托管在Heroku上。 On default, it looks like Heroku supports https (eg. https://yodel-site.herokuapp.com ), but not when you go to my site with https://yodel.co - although it works with just http://. 默认情况下,似乎Heroku支持https(例如https://yodel-site.herokuapp.com ),但是当您使用https://yodel.co转到我的网站时不支持-尽管它仅适用于http:/ /。

What do I need to do in order for SSL (https) to work on my custom domain in Heroku? 为了使SSL(https)在Heroku中的自定义域上起作用,我需要做什么? Is it something to configure in my DNS ( PointHQ ), or do I need to pay heroku for the addon ? 是否需要在DNS( PointHQ )中进行配置,还是需要为该插件支付heroku的费用?

Here's what my Heroku custom domains section looks like: 这是我的Heroku自定义域部分的样子: 在此处输入图片说明

You will have to pay Heroku for the add-on, acquire an SSL cert, and install it according to their instructions . 您将需要向Heroku支付附件的费用,获取SSL证书,然后根据其说明进行安装。 Note also that you should probably avoid installing SSL at the apex , and redirect any apex traffic to the subdomain you do choose (eg www). 还要注意,您可能应该避免在apex处安装SSL ,并将所有apex流量重定向到您选择的子域(例如www)。

Using CloudFlare is a reasonable approach to avoid paying Heroku's charges, though the certificate that's presented will not be your own. 使用CloudFlare是避免支付Heroku费用的一种合理方法,尽管提供的证书不是您自己的。 You can make the choice about whether it's worth the money. 您可以选择是否值得。

The simplest and cheapest way is to upgrade from Free to Hobby Dynos, it will cost a maximum of 7$/month for a small app, and actually probably much less because the price is prorated to the time your Dyno will run per month.( https://www.heroku.com/pricing ) This is much cheaper than the 20$/month to get the SSL Heroku add-on. 最简单,最便宜的方法是从Free升级到Hobby Dynos,一个小型应用程序的每月最高费用为7美元,而实际上可能要便宜得多,因为价格按比例分配给您的Dyno每月运行的时间。( https://www.heroku.com/pricing )这比获得SSL Heroku附加组件的每月20美元便宜得多。

Once you have upgraded your plan from Free to Hobby, things are pretty straightforward: 将您的计划从“免费”升级到“爱好”之后,事情就很简单了:

  • Go to your app on Heroku, go to settings, scroll down to domains and certificates, and add your domain: www.yourdomain.com 在Heroku上转到您的应用,转到设置,向下滚动到域和证书,​​然后添加您的域:www.yourdomain.com
  • This will automatically give you a DNS target as such www.yourdomain.com.herokudns.com 这将自动为您提供DNS目标,例如www.yourdomain.com.herokudns.com
  • In your Domain Host: 在您的域名托管服务商中:
    • Add a CNAME record using this DNS target, for instance on Godaddy as such: Type: CNAME Name: www. 使用此DNS目标添加CNAME记录,例如在Godaddy上,如下所示:类型:CNAME名称:www。 Value: www.yourdomain.com.herokudns.com 值:www.yourdomain.com.herokudns.com
    • Add a redirect action from your root domain (yourdomain.com) to www.yourdomain.com 将重定向操作从您的根域(yourdomain.com)添加到www.yourdomain.com

Allow a few hours for the DNS changes to propagate, and you're all set! 等待几个小时让DNS更改传播,您就一切就绪!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM