9

Heroku custom domains

I've setup two custom domains for my Heroku app.

example.com        example.com.herokudns.com
*.example.com      wildcard.example.com.herokudns.com

Domain configuration

I configured my domain as follows:

  1. I added a CNAME Record for * pointing to wildcard.example.com.herokudns.com.
    Works fine.

  2. I forwarded my URL using GoDaddy's Domain Forwarding tool, because I can only specify IP addresses as A records.


Problem

The domain forwarding points to example.com.herokudns.com. Unfortunately GoDaddy automatically prepends http://, so it actually does not open my app and instead shows a Heroku message:

There's nothing here, yet.


Goal

Setting up my GoDaddy root domain to point to my Heroku app.


Note: GoDaddy automatically added an A record for @ pointing to >>++FWD1++<<

heroxav
  • 1,387
  • 1
  • 22
  • 65

4 Answers4

15

Cloudflare does the job!

Finally, I achieved my goal of using my naked domain as host by choosing CloudFlare to handle my DNS configuration.

Resources:


Note: CloudFlare has a pretty good documentation and setup process, you just need to:

  1. add your domain to CloudFlare
  2. follow the CloudFlare setup guide
    • updating your nameservers (in my case GoDaddy) to point to CloudFlare
temporary_user_name
  • 35,956
  • 47
  • 141
  • 220
heroxav
  • 1,387
  • 1
  • 22
  • 65
  • make sure that you have Heroku set to receive ssl on it's dashboard, then on CloudFlare set the sll to **full** instead of _flexible_ – CelsoDeSa Sep 01 '19 at 13:16
2

What did you set your DNS to forward to? I had this same problem, but solved this creating a Heroku DNS entry for www.myapp.com. Heroku creates a DNS target of www.myapp.com.herokudns.com.

Here is my setup:

  • DNS forwarding to www.myapp.com
  • DNS CName of www to www.myapp.com.herokudns.com
  • Heroku DNS added www.myapp.com
Mathew Kleppin
  • 302
  • 2
  • 7
0

You can also achieve this by setting up a nginx server with docker in five minutes.

First follow the instruction on this link: https://pentacent.medium.com/nginx-and-lets-encrypt-with-docker-in-less-than-5-minutes-b4b8a60d3a71

Then add your nginx server ip to your A Record with host name @

In you nginx server you can use this code to redirect all traffic to your naked domain to www domain. Just replace all your-domain.com with your domain.

server {
  listen 80;
  server_name your-domain.com;

  location /.well-known/acme-challenge/ {
    root /var/www/certbot;
  }

  location / {
      return 301 https://www.your-domain.com;
  }
}
server {
  listen 443 ssl;
  server_name your-domain.com;

  include /etc/letsencrypt/options-ssl-nginx.conf;
  ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;

  ssl_certificate /etc/letsencrypt/live/your-domain.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/your-domain.com/privkey.pem;


  location / {
      return 301 https://www.your-domain.com$request_uri;
  }

}
mcnk
  • 1,690
  • 3
  • 20
  • 29
-4

In Setup Heroku and GoDaddy? allegutta solves the issue by masking the heroku-app-name domain with the .com domain. Instead of slooob.com.herokudns.com, use your original heroku app url ([heroku-app].herokuapp.com) and it should work. Just worked for me.

Community
  • 1
  • 1
  • For me that does show the url `[heroku-app].herokuapp.com` in the browser address bar, if I redirect to `http://[heroku-app].herokuapp.com`. Is it possible to use `slooob.com`? – heroxav Jan 08 '17 at 12:22
  • You mean when you enter sloob.com the user is redirected to the real app url? That shouldn't happen. – Eduardo Roxius Jan 15 '17 at 15:52
  • 1
    I mean the redirection shouldn't happen. Is it still like that? If so, can you post a picture of your CNAME records? – Eduardo Roxius Jan 15 '17 at 20:12
  • Ah, yea the point was that I want to prevent redirecting from `slooob.com` to `www.slooob.com`. I achieved this at the end by using CloudFlare's Alias Record. – heroxav Jan 15 '17 at 20:35