Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure DNS on Heroku (pointdns)

Tags:

heroku

dns

I have the following configuration in pointDNS:

* SOA example.com dnsx.pointhq.com, admin.xxx.com, ...
* ALIAS example.com xxx.herokussl.com.
* CNAME www.example.com. xxx.herokussl.com. (same as above)
* NX example.com dnsx.xxx.com (same as above)
* NX example.com dnsy.pointhq.com (different)

I did not make this initial configuration and now trying to understand what this means.

The main issue is the fact when we visit example.com we are redirected to https://example.com and when we visit www.example.com we're redirected to https://www.example.com.

How can I solve this in the configuration above?

like image 982
DenCowboy Avatar asked Jul 28 '18 22:07

DenCowboy


People also ask

How do I add a DNS to Heroku?

Summary of stepsAdd the custom domain to your app with the heroku domains:add command. Look up the Heroku-supplied DNS target for the custom domain using the heroku domains command. Configure your app's DNS provider to point to the Heroku-supplied DNS target. Confirm that your app is accessible via the custom domain.

How do I get my CNAME from Heroku?

You can check the correct CNAME target for Heroku SSL (SNI) by running the Heroku CLI command: heroku domains -a your_app_name . You might have old Custom Domains that still display a your_app_name.herokuapp.com CNAME target. You should remove, and re-add these to ensure a herokudns.com CNAME is set up.

How do I redirect my domain to Heroku?

Go to the record editor and two DNS records, one for each host name, pointing to the Heroku SSL endpoint: Add an ALIAS record to point example.com to Heroku. Leave the Name of the record empty and set the Content field to the SSL endpoint example.com.herokudns.com. Add a CNAME record to point www.example.com to Heroku.

How do I find my Heroku name server?

Heroku doesn't provide DNS services therefore there are no name servers. You use your domain name registrars control panel to point your DNS records at your Heroku application. Typically this is a CNAME record pointing at the . herokuapp.com entry.

How do I point my DNS provider to Heroku?

After you add a domain with the heroku domains:add command, you need to point your DNS provider at the DNS target provided by Heroku. You can view this DNS target with the heroku domains command (see View existing domains for details). You usually configure a new CNAME record with your DNS provider to point it at Heroku.

How do I add a custom domain to Heroku?

Add the custom domain to your app with the heroku domains:add command. Look up the Heroku-supplied DNS target for the custom domain using the heroku domains command. Configure your app’s DNS provider to point to the Heroku-supplied DNS target. Confirm that your app is accessible via the custom domain.

How many domains can a Heroku app have?

Instead of explicitly verifying domain ownership, Heroku enforces the following rules to ensure that domains aren’t claimed by multiple users or apps: A single app can have up to 10,000 custom domains assigned to it. A given domain can be added to only a single Heroku app.

Which Heroku browsing address should you use?

Which one should you use? All Heroku applications are browsable via the your_app_name.herokuapp.com address, however, to use Custom Domains, you will need to setup your DNS to use the correct CNAME targets, which differ depending on how your application is setup.


1 Answers

In case you would also like to receive/send email using your custom domain, probably the easiest way would be to use Cloudflare, check Heroku docs for: Configuring DNS for root domains

Within Cloudflare to redirect example.com to www.example.com you could create a Page rule:

example.com/*

You'd then setup the following URL for traffic to forward to:

https://www.example.com/$1

To do the redirect with PointDNS you will have to delete first the Alias:

enter image description here

Then click on the redirect icon and don't type any name: enter image description here

If you haven't delete the ALIAS record you will get the warning shown in the picture

enter image description here

Once you create the redirect it should look like this:

enter image description here

Common Runtime - SSL Endpoint

If you’re using the SSL Endpoint, note that your DNS Targets will be a little different. For apps in the Common Runtime, the endpoint domain name will vary depending on region. The US region will have a name in the form of example-2121.herokussl.com. Apps in the EU region will have the same domain name as your app’s herokuapp domain, e.g. my-app-name.herokuapp.com.

like image 86
nbari Avatar answered Nov 11 '22 01:11

nbari