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

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.

Related

heroku cloudflare subdomain SSL setup

I'm trying to set up https on my backend app on heroku as a subdomain like this (for example):
https://api.mydomain.com
and I'm really confused by all the conflicting online docs I've found. Also, I'm rather green on all this SSL stuff. This app will be a backend for just data serving. My front end right now is https on OpenShift under my domain and it's working fine. Here is what I've done:
I have a "hobby" dyno ($7/month) on my heroku app, which I read that I need to
enable this stuff.
I have a cloudflare account which serves up my domain for the openshift front-end on https.
I bought my domain from GoDaddy -- so right now it simply points to the cloudflare name servers.
I setup the subdomain: api.mydomain.com on heroku (settings tab). It came back and said that my "DNS Target" is api.mydomain.com.herokudns.com. It also says "Domain: Your app can be found at http://api.mydomain.com".
I clicked "Configure SSL" > "Automatically configure using Automated Certificate Management" and it comes back saying to:
"update your DNS settings to our secure domain"
Not really sure what that means, to be honest. I tried to go back to cloudflare and add a DNS Record (DNS tab). Like so:
Type: CNAME
Name: api <--is this right?
Value: api.mydomain.com.herokudns.com <-- what do I put here?
But this doesn't work. How do I know? I type
heroku certs:auto and it comes back 'failing'. Also tried value: mydomain.com.herokudns.com without the 'api' in front. I'm really confused and the docs aren't much help. Can anybody help me?
I have found a simpler solution. The fix was mentionned in Cloudflare's tutorial.
The trick is to take your standard heroku app address (ex: myapp.herokuapp.com) INSTEAD of the xxx.herokudns.com displayed in heroku's SSL interface
Then, to make your custom subdomain (ex: api.foodomain.com) point to it, simply add a CNAME record in Cloudflare's DNS
CNAME api myapp.herokuapp.com
And it should work (it did for my case).
OK, in case some other poor tired programmer comes here.
Cloudflare and Heroku don't get along. Use your SSL from cloudflare. Here's how:
disable automatic certification on heroku: heroku
certs:auto:disable
Delete your domain on heroku and start over
Add the (sub) domain again on heroku
type heroku domains to see what the REAL domain is now -- without ACM enabled it will probably go back to ...herokuapp.com instead of ...herokudns.com
Set that one up in cloudflare (DNS tab) under CNAME like so:
CNAME | yoursubdomainname | yourdomainname.com.herokuapp.com
set up Page Rules in cloudflare to be like so:
http://yourdomainname.com/ => Always use https
on Crypto tab use Full SSL.
Wait an hour or so to make sure these all take effect.
Hope that helps someone.

Allow my users to point their subdomains to my server with CNAME, without having to use add-on domain in cpanel

So I have a service that allows my user to map their own subdomains to my server. For example
http://sub.userdomain.com will map to http://sub.mydomain.com
Now I know that the user must add a CNAME record that points to my subdomain, but using Apache & Cpanel, now I have to add an add-on domain for this connection to work.
Is there a workaround so that I don't have to set up this add-on domain for the connection to automatically connect? (Basically so that my user can point their CNAME to my subdomain and it then automagically works without me having to do manual input).
Hope that makes sense!
No, You need to add addon domain on your server so that cPanel will create entry in apache configuration to work that domain.

Domain Already Exists in the Apache configuration

I'm getting an error:
Account Creation Status: failed
(XID s9wshe) The domain "mydomain.com” already exists in the Apache configuration.
This site was originally on Server 1. These are the nameservers:
NS1.DOMAIN.COM
NS2.DOMAIN.COM
He bought a secondary server. These are the nameservers:
NS3.DOMAIN.COM
NS4.DOMAIN.COM
I'm trying to move sites from the 1st server to the new server. He has add-on domains and sub accounts inside individual accounts in the WHM.
This specific website was added on inside one of these accounts (instead of being given it's own account in WHM). I believe that is why I am having this issue.
My question is what is the best way to configure the new account on the secondary server without taking the old site down for anything other than the domain nameserver change?
Figure out which server is currently being used by the nameservers of the domain. It sounds like you may have the DNS tied between the servers. As long as the domain is pointed at the other server's nameservers you can simply delete the DNS zone on the server you are trying to create the account on and then you should be able to add it. Afterwards, simply create the DNS zone again.
In my case I had a GoDaddy shared hosting with multiple add-on domains, When I tried to delete an addon domain and recreate it again, I got this error (Domain already exists in the Apache configuration). I fixed it by going to the alias under the domain section in Cpanel. Then deleted the alias. Waited a bit, then try to do the steps again. It worked for me.

Multi-Domain SSL setup with pointers

I have one server, with DirectAdmin, with the main-domain DomainA.com. Other local domains, like DomainA.co.uk, DomainA.fr and DomainA.de are pointed (alias) to this main-domain. When someone visits a local domain, it's internally redirected to DomainA.com, where some code recognizes the domain an shows the website in the local language without redirecting the visitor to DomainA.com.
This is working fine, but now I want to use SSL on all the domainnames. Is this possible with the current setup?
You can use a certificate with subject alternative names or use for a solution like CloudSSL from GlobalSign: https://www.globalsign.com/cloud/

Apache Multiple Subdomain DNS Handling

I am currently building an application that I will host and will have multi-tenants (SaaS) called over the web, I would like them to be able to have subdomain.theircompany.com be able to point to subdomain.mycompany.com (or if they wish, point a full TLD to a subdomain with me).
The way I have been expecting this to work is to simply have a wildcard 'ServerAlias *.mycompany.com' in my Apache config pointing to my application, which then extracts the host being called...They then redirect via a CNAME entry on their host.
My question is, would this approach allow external subdomains to be pointed to a CNAME URL instead of IP? As this runs on one account on my system, am I able to install an SSL for a single wildcard if that customers wants to be running on SSL?
Any other suggestions/approaches would be greatly appreciated!
Thanks
A CNAME will work for the purposes of naming, but not for the purposes of a wildcard SSL cert.
Specifically, example.theircompany.com can have a CNAME record with a value of example.yourcompany.com. This will mean that example.theircompany.com will transparently resolve to your site. In other words, a browser still sees example.theircompany.com, not example.yourcompany.com.
As such, the SSL cert must be for the theircompany.com domain, not the yourcompany.com domain.