We have recently added custom domain support for some neeto products. We are directly adding custom domains in Heroku and not using any third-party service.
Heroku custom domains
We can add custom domains in Heroku if we are using Hobby or Professional plan. Let's add a new custom domain in Heroku.

After adding the domain we will get the DNS target which we have to add as a CNAME record in our domain's ( dingan.org )DNS. Now let's add the NAME record for help.dingan.org.

After adding the CNAME if we try to access help.dingan.org we see that the connection is not secured. This is because we have not added any SSL certificate for help.dingan.org . We can add SSL certificates in the Heroku certificate section. After adding a self-signed SSL certificate for help.dingan.org in Heroku, we were able to establish a secured connection using help.dingan.org. Now let's discuss how we automated the whole process.
Automation
-
SSL certificate requests
Before adding a new custom domain in Heroku we need an SSL certificate for that domain. We have used Let's encrypt for creating certificates. For using lets-encrypt we need a client. Since we are using ruby for the back end we chose the acme-client gem. You can see the list of available clients here.
-
Heroku requests
For adding custom domains and certificates in Heroku we used the Heroku platform apis.
Complete workflow
Customer gives their custom domain (
help.dingan.org)We request an SSL certificate for
help.dingan.orgfrom Let's encrypt usingacme-clientCustomer has to validate their domain (
dingan.org) for getting the certificate. We are using TXT validation so they have to add a txt record in their DNS with a value provided by Let's encrypt.Once the domain is validated we will get the certificate and add the certificate in Heroku using the platform API. We get the certificate name from the response.
We add the custom domain (
help.dingan.org) in Heroku with the received certificate name.Customer has to create a CNAME record with the value received from Heroku.