Configure DNS for root domain on Namecheap - heroku

Relatively new to coding and was looking for some help on configuring the DNS for a root domain. I've been following this heroku guide on adding a custom root domain and am currently stuck since the guide doesn't have specific rules on if your DNS provider is Namecheap (where I got my domain from).
To clarify, I have the domain gperalta.com and would like it to show the page I made at https://guarded-caverns-49596.herokuapp.com/. The closest I've been to having this work is having Namecheap redirect from gperalta to the herokuapp URL. But I'd like the URL itself to remain as 'gperalta.com' instead of defaulting back to the herokuapp URL.
Namecheap lists a Type, Host, Value, and TTS under their Advanced DNS Section. For reference, here are the options for what you can choose for Type:
A Record
A+ Dynamic DNS Record
AAAA Record
CNAME Record
NS Record
SRV Record
TXT Record
URL Redirect Record
Haven't been able to find anything on Namecheap (closest answer I found involves using an IP address, but heroku doesn't keep a consistent IP for apps) or stackoverflow so far, so any help would be much appreciated.

I hope this helps you get started. https://www.namecheap.com/support/knowledgebase/article.aspx/9737/2208/pointing-a-domain-to-the-heroku-app
In the future, Namecheap has an always-accessible 24/7/365 Live Chat and ticket platform so you should expect to get answers quicker.

Related

How to associate Heroku app with a Google domain?

I purchased a domain with Google and I would like to associate it with a Heroku app. What is the step-by-step process to achieve that?
I recently connected my app to a custom domain. Although my domain is purchased from AWS route53. I think the approach generally is the same.
First of all, you can check out this page written by Heroku. https://devcenter.heroku.com/articles/custom-domains
I believe the tutorial given by Heroku works. However, I am tired of all those CLI that make things unvisable XD. Luckily, we can configure it from the Heroku website instead of the CLI.
Here is my approach:
First open your app in the Heroku web page, then click the "Settings" button
https://dashboard.heroku.com/apps/{your app name}
Scroll down until you see the "Domains" section, Then click "Add domain"
https://dashboard.heroku.com/apps/{your app name}/settings
Input the domain name you purchased from google (eg. www.example.com)
After adding your domain, Heroku will give you the DNS target.
From your google domain DNS management page, you should be able to add a new record for your hosted zone.
Finally, add a new record with simple routing policy, type CNAME, and value equals to the DNS target provided by Heroku.
It is really simple if you follow these steps correctly. Due to my reputation level, I cannot upload photos. Feel free to contact me if you want some image to guide you how to locate the buttons :)
It’s only 3 steps:
1. Heroku, in your app > Settings > Add your domain:
Add www.[foo.com] (Note: www is KEY!) to your app
Copy the [DNS Target] it gives you
2.Google Domains > DNS > Resource records > Custom Records > Manage Custom Records:
www, CNAME, [DNS Target]
Now you’re basically set up. If someone goes to https://www.[foo.com] in a few minutes, they’ll see your Heroku app hosted at [DNS Target]. But if they go to any other permutation (http, non-www) they’ll get a 404 error. To solve this, we’ll set up permanent redirects to the main version in the next step.
Google Domains > Website > Add a Forwarding Address:
From Field: [foo.com]
To Field: https://www.[foo.com]
Permanent Redirect (301)
Forward Path (so that [foo.com]/about forwards to https://www.[foo.com]/about)
SSL Enabled
Boom. Wait a couple of minutes for DNS to catch up, and you’re done.
heroku certs:auto:refresh
In Terminal refresh the SSL cert settings on Heroku, and check the Heroku Dashboard to confirm everything’s working.
Confirm all the below permutations forward to your site correctly:
https:
https://www.[foo.com]
https://[foo.com]
http:
http://www.[foo.com]
http://[foo.com]
paths:
https://www.[foo.com]/about
http://[foo.com]/about
PS: So does this work for the naked domain like [foo.com] instead of www.[foo.com]? No! Google Domains does not support ALIAS domains, and therefore in combination with Heroku does not support forwarding to the naked (aka. root aka. apex) domain. Sorry! This surprised me too :( Source 1: Heroku Docs | Source 2: StackOverflow. Your only alternative here is to transfer your domain (which costs money) to something like Cloudflare.
A working answer with these explanations is taken from https://nikodunk.com/heroku-ssl-google-domains-2019/
Just to add to Fergus's answer, if you are seeing the warning "cant add cname records as root domain" add www to the host name input.

Domain name not routing with Heroku and Namecheap

I recently purchased a domain name with namecheap.com, and added a CNAME record from my Heroku app where I am running the application. I am sure that I added the correct domain name to my Heroku app, and the correct DNS target to my CNAME on Namecheap web settings.
Previously it was working, but this morning I purchased an SSL certificate on Namecheap, and my domain just points to a Namecheap page saying "This domain is registered with Namecheap".
I followed all the steps to properly activate the SSL certificate, and it even says it's activated on Namecheap on the domain I want. Also what's strange is the the Heroku domains appear to have good ACM status.
So on the surface everything seems to be all right, but when you go to my domain my app doesn't show up.
Any idea as to why this is? Also if you have any more information you want to know feel free to ask.
I figured it out. I had to delete the default records on the domain. Initially namecheap sets a reroute, and CNAME for their parking lot page.
These need to be removed so that they don't interfere with the domain routing that you want.

Pointing domain to Heroku application with wildcard

I have an application where users get their own subdomain, like site1.mysite.example. I would like to allow users to register a custom domain that they can point to to their sub domain but I'm having trouble figuring how to configure Heroku and my DNS settings to allow this.
In my DNS settings for my domain I have a CNAME record setup like so:
Host = *
Value = sites.mysite.example
The value here is an app I have running which will translate the subdomain (site1.mysite.example) to figure out which site to load.
I have a CNAME for mysite.com which points to Heroku's DNS site:
Host = sites.mysite.example
Value = mysite.example.herokudns.com
On the domain I'm testing with I have a CNAME record setup like this:
Host = docs.othersite.example
Value = site1.mysite.example - this is the subdomain they get on my site
But for some reason this is not working. If I register site1.mysite.example as the custom domain in my application and I run dig site1.mysite.example I get the following:
;; ANSWER SECTION:
docs.othersite.example IN CNAME site1.mysite.example
site1.mysite.example IN CNAME sites.mysite.example
sites.mysite.example IN CNAME mysite.example.herokudns.com.
When I try docs.othersite.example in a browser I get Heroku's There's nothing here, yet. page. So it seems like Heroku is not loading up my application. I am guessing this is because I do not have docs.othersite.example registered as a domain in my Heroku application, but I do not want to have to register every custom domain. Also, I do not own these domains so I could not anyway.
What am I doing wrong here? Any help is much appreciated. I'm happy to post any more info someone needs or clarify anything.
Heroku does support wildcard domains, so in this case you could add *.othersite.example to your Heorku app's custom domains.
If you need to support different root domains (othersite2.example, othersite3.example) for each user, there's no easy way to support that. You'd need use Heroku's Platform API to programmatically manage custom domains.

Configure DNS to work with both heroku and google suite

I currently have 3 DNS records:
www.erbij.app - CNAME - www.erbij.app.herokudns.com
api.erbij.app - CNAME - api.erbij.app.herokudns.com
erbij.app - CNAME - erbij.app.herokudns.com
Our web app and api are functioning fine. However, I'd like to have our email hosted by Google Suite, so I'm trying to add MX records:
erbij.app - MX - ASPMX.L.GOOGLE.COM.
But I get an error that I can't have two records for erbij.app.
I've tried contacting my domain registrar, but they don't have a blue.
In this SO question the possible solution of subdomain redirection is mentioned, but how does this work? If erbij.app is not pointing to a server, how can I use server software to redirect all requests to www.erbij.app?
My apologies if this is a silly question. I know very little about DNS records.
I ended up signing up for CloudFlare (thanks Luke Ramsden for the tip) to manage my DNS. Cloudflare does allow users to add CNAME/ALIAS records to the root domain.
Simply change the nameservers in the control panel of your registrar, configure the domain on cloudflare.com and you're done.
Is you zone erbij.app? In that case you shouldn't have a CNAME record that has the same name as your zone in the first place, and also, a CNAME record name must be unique so you cannot have an MX with that name if you have the CNAME

How to configure DNS records for Name.com and a Heroku app

I'm a bit confused about how to set up the DNS records for my domain at Name.com so it can correctly point to my Heroku app.
I found DNS configuration documentation at heroku's site but I'm still confused.
I'm under the impression that I need to set up a CNAME record for all subdomains and an A record for my root domain.
Also, on the name.com website, when I try to add a CNAME there are three blank fields I need to fill out which kind of confuse me: "Host" (where I enter '*' so it applies to all subdomains?), "Answer" (where I enter the DNS Target?), and "TTL"
Any help would be greatly appreciated. Thank you.
Fully detailed steps (2)
1). Visit Heroku apps dashboard
Choose your app
Click "Settings"
Find text "Add Domain", click button
Add your site with www subdomain:
www.yoursitename.com
Copy the returned "DNS target" value
2). Visit your name.com account
Find link text "Manage DNS Records" and visit link
"ADD RECORD" row with the following content:
Type:
Host:
Answer:
CNAME
www
📋 DNS target value from clipboard
(SAUMITRA KUMAR's answer, is what helped me write this answer.)
Don't use an A-record for your root domain. Heroku is using volatile IP addresses, which means the IP you configure in your A record can stop working at any moment without notice.
See https://devcenter.heroku.com/articles/apex-domains
On your root domain, you need to either setup an HTTP redirect to your www subdomain with your DNS provider, or use another provider which offers CNAME records for root domains.
As for the CNAME in your subdomains, yes, "Host" would be "*" to be all your subdomains.
Answer will be the endpoint provided by heroku, in the form appname.herokudns.com..
TTL means how often the DNS cache should be refreshed with the clients. Using the default (or 3600 if they don't provide any) will work here.
Here's what worked for me. Start with typing this in the Heroku CLI
Heroku domains: add www.youwebsitename.com --app yourherokuapp
This should give you a DNS target.You can obtain this from the your app settings as well on the website . Copy it and save it because we are going to need it later.Then after this run
heroku domains:wait for www.youwebsitename.com --app yourherokuapp
Then visit name.com and under your domains visit your dns records . There add CNAME entry with HOST equal to "www.yourwebsite.com" and ANSWER equal to whatever the dns target that heroku supplied you with .
Go ahead and visit your website , it'll work , if it doesn't make sure that you've used www with your website name . To fix this issue add an ANAME entry with "yourwebsite.com" as HOST and heroku dns again as target . It should reflect the changes within few hours .

Resources