Aldo
Aldo

Reputation: 171

How to setup domain with SSL in Heroku

I am trying to setup my own domain with an SSL certificate but I just can't get it right. Do I have to put as a DNS the app URL or the DNS generated when I add my domain? I am using GoDaddy and I have seen a lot tutorials saying some of them that you have to use the *.herokuapp.com DNS and other say that the DNS generated in Heroku.

Also, when I look for my app in Google it says that the certificate is not valid for *.herokuapp.com but the one I uploaded was for my personal domain!

At last, sometimes I get the error NET::ERR_CERT_COMMON_NAME_INVALID, can someone help me please?

Upvotes: 2

Views: 3109

Answers (1)

Chris
Chris

Reputation: 136880

Automatic Certificate Management (ACM)

The simplest solution doesn't even require you to buy an SSL certificate, but you do need a paid dyno on Heroku. The $7 hobby tier works fine.

  1. Add the custom domain to your app's domains using the CLI or web interface:

    heroku domains:add www.custom-domain.com
    
  2. Run heroku domains to see what your Heroku DNS target is (this is probably your-app.herokudns.com—note that this is not a .herokuapp.com domain)

  3. Add a CNAME record in your DNS registrar pointing to your DNS target

  4. Enable ACM by running

    heroku certs:auto:enable
    
  5. Wait for your certificate to be generated and enabled

    It takes approximately 45 - 60 minutes to fully generate a TLS certificate for custom domains on your application. You can view the status of the certificate that is generated for all of your custom domains by running:

    heroku certs:auto
    

    If your status says “DNS Verified”, the process is not finished yet. It means we have verified your domain status and are still in the process of submitting it to Let’s Encrypt. The process will be complete when it says “OK”.

Congratulations! Your site should now have ACM enabled.

ACM is powered by Let's Encrypt, a fantastic free service for adding HTTPS to the web.

Custom certificates

It is also possible to set up HTTPS on Heroku using a custom TLS certificate. But ACM is much easier, and that's what I recommend using.

Upvotes: 4

Related Questions