简体   繁体   中英

How to set up SSL for naked domain from Google Domains to Heroku?

I'm trying to use Heroku's Automatic Certificate Management to set up SSL for my site. My app is on heroku at myapp.herokuapp.com , and I currently have Subdomain Forwarding set up so that http://www.myapp.com properly shows my app.

What I want is to have my site hosted at https://myapp.com .

I ran heroku certs:auto:enable , but it shows:

=== Automatic Certificate Management is enabled on myapp

Domain             Status
─────────────────  ───────────
www.myapp.com      Failing

Running heroku domains shows:

=== myapp Heroku Domain
myapp.herokuapp.com

=== myapp Custom Domains
Domain Name        DNS Target
─────────────────  ───────────────────────────────
www.myapp.com      www.myapp.com.herokudns.com

Right now, in Google Domains, I have a Subdomain Forward from @.myapp.com to http://www.myapp.com . I also have a Custom Resource Record with the name www , type CNAME , and data myapp.herokuapp.com. .

What do I need to change in my setup so that I can host my site at https://myapp.com ?

Unfortunately, Google Domains does not support the ANAME or ALIAS record. You must use one of these for your apex domain. Here's the full list supported by Google Domains.

https://support.google.com/domains/answer/3290350

Heroku has a list of DNS providers that support the ALIAS or ANAME records here: https://devcenter.heroku.com/articles/custom-domains#add-a-custom-root-domain Personally, I use DNSimple and have had great success with them.

The CNAME target needs to be www.myapp.com.herokudns.com . In your question above you only have the apex record in your DNS in myapp.com.herokudns.com . If this is not the case can you share the domain so I can dig the record for more information?

I've had the same problem with Heroku and other PaaS providers over and over: depending who provides and manages the DNS for your domain you may or may not able to use a CNAME or ALIAS record on the naked domain. That's why we've created a simple service to solve this by applying a simple SSL redirection from the naked domain to the "www" under SSL, without changing your DNS management provider: NakedSSL will give you an IP and will create and host an SSL certificate for your naked domain ( https://yourdomain.com ), redirecting it to the HTTPS URL that you want (most likely " https://www.yourdomain.com ").

Disclaimer: I'm obviously part of the team that created NakedSSL. I hope you don't take this as self-promotion (anyway we offer it for free for 1 domain, which totally fits the needs of 95% of developers/hobbyist out there), but as a way to deal with this annoying situation in an easy way.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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