4
I bought a domain and need to configure together my application that is in Heroku. How to do this?
4
I bought a domain and need to configure together my application that is in Heroku. How to do this?
2
To configure your application’s domain, it is directly in the application’s settings and accessing the "Domains" section. Looking at the documentation (custom-Domains). It ensures that requests made to the custom address and that points to the address of your application in Heroku (xxxxxx.herokuapp.com
) be attended to.
You will need to set up a CNAME or ADDRESS (CNAME is more reliable since your Heroku domain never changes, the IP may change depending on the Heroku policy) of the domain you want to xxxxxx.herokuapp.com
on your DNS provider.
I just made a test: in the "Domain" options put only the address without www
, for example: nome_do_domino.com
. On your DNS provider create a CNAME record of nome_do_domino.com
pointing to nome_da_aplicacao.herokuapp.com
. In a short time the address becomes accessible.
1
While using the method nome-do-app.herokuapp.com
works, Heroku’s Automatic Certificate Manager (ACM) will fail and you nay you will be able to use your domain with an HTTPS session, HTTP only. In order for ACM not to fail, you will need to use DNS target.
Since it took me a long time to find a solution and this question was one of the ones that came up when I Googled, I decided to post what I learned so I could help those who are lost. Moreover, the answers given above do not resolve completely the problem in 2020.
Here I will try to be as complete as possible by taking a step by step, but the direct answer to the question is in Step 4. If the location you purchased the domain has support for Records guy ANAME
or ALIAS
, can skip steps 1 and 2.
Depends. You can use the DNS server itself if it provides support for Records type ANAME
/ALIAS
, because Heroku requires it for root domains. Without it, although you can use www
(ex.: https://www.meu-dominio.com
), cannot use root for your domain (eg.: https://meu-dominio.com
). Currently many people no longer type the www
at the beginning and, although some modern browsers put the prefix automatically, you run the risk of your visitor typing and unable to access your site.
If you just want to register the www
and do not want to use Pointdns, skip to the step 3.
To properly configure ACM along with Pointdns you need to add this add-on to at least one of your apps. Note that, not necessarily you need to set up Pointdns for the app it’s connected to and can direct subdomains to other apps. As a personal experience, I have the add-on in my production app and also use it to configure the staging.
To configure:
heroku addons:create pointdns:developer
.This plan is free and allows 10 Records with 10,000 monthly redirects (more than enough for a personal project).
If you haven’t done it yet, no problem, let’s do it now.
Before logging into your account where you registered your domain, see list of Nameservers in the Pointdns app (you will need to be logged in) and choose the 3 that have the best location (at the time of writing they recommend 3). Add these 3 chosen ones to the list of Records like NS
.
Now entering your account, browse the settings and follow the steps (based on the.br registry):
Alterar Servidores DNS
.If you haven’t already done this before, this yes you need to add in the app you will use in Heroku. To add, use:
heroku domains:add www.example-domain.com
. Then type the command heroku domains
and copy the target DNS that will appear, you will need it after.Obs. 1: DNS target will be something in the format papagaio-brasileiro-13fqwefrr4r.herokudns.com
or something similar that ends in .herokudns.com
Obs. 2: Remember that meu-dominio.com
and www.meu-dominio.com
are 2 Records and, if you want to cover both user spellings, you will need to register both.
If you’ve been using Pointdns and you’ve been through step 3, probably when accessing the interface you will already see some Records automatically written. Although they are valid to access the site, they will not work with ACM (Automatic Certificate Manager). For this you should use the DNS targets I said I would need on step 2.
Obs: For mastery root (that is, without the www.
at the front, only meu-dominio.com
) you need obligatorily type ALIAS
when setting up the record. DO NOT USE CNAME TYPE FOR ROOT DOMAINS. For all the others Records subdomain (www
, staging
, etc), use the type CNAME
.
Only wait for at least 2 hours for these changes to spread. It looks like a beast, but I made a lot of mistakes in that part. When the changes are complete, ACM will automatically validate SSL certificates and you won’t have to worry about that anymore.
0
The problem is that the "Naked Domain" (xxx.com.br) cannot be a CNAME. What can be done is 1) Create a CNAME from www.xxx.com.br for application.herokuapp.com name_name 2) Place an A entry pointing to 174.129.25.170
This IP is from a service that redirects domains without www to www.dominio , more details in this URL:
Browser other questions tagged ruby-on-rails heroku
You are not signed in. Login or sign up in order to post.
Oops, beauty @Wakim... I’ll try it here! Thank you.
– Jefferson Alison
The problem with the.br record is not having asterisk support on
CNAME
*.bar.com.br
, another alternative is using fixed IP onA
but with Heroku, fixed IP is even more complicated, initially only offers by address. As it is?– Adriano Resende