设置 Heroku 和 GoDaddy?

我试图得到一个域名,我买了通过 GoDaddy 与我的 Heroku 托管网站工作。

我如何配置我的域名与 Heroku 工作?

37017 次浏览

DNS settings tend to have a lag time.

Have you attempted to access the app from another device? (Say a smart phone that is operating on another network?) I've seen on several occasions where my local dns cache was causing issues which is why accessing it from another device may shine some light on your situation.

If you're making the dns changes from a windows based pc you can flush your dns cache which can sometimes resolve your issue.

1.) Right Click on CMD.exe (aka command prompt) 2.) Click on Run as Administrator. 3.) type: ipconfig /flushdns 4.) Press Enter key

But bear in mind dns changes can take a while to propagate.

Go to https://dnsimple.com/r/ecc41c23013629 and open an account.

They have a one click set up for heroku and you can set the TTL to as low as one minute. Then on the GoDaddy side just change the dns servers from the go daddy servers to the dnsimple ones(all explained on the dnsimple site). SIMPLE ;)

Your domain is still hosted by GoDaddy

GoDaddy is not the place to be managing you dns in my humble opinion.

[Updated 31.10.2014] Allright! It works! Here is how I did it from scratch, so others with the same problem can fix it too. First I will explain how to setup Heroku and GoDaddy, then I will explain how to create a naked domain (www.example.com -> example.com).

Setup Heroku and GoDaddy:

  1. In your project folder in terminal (on your computer) write heroku domains:add www.example.com (where www.example.com is the domain you have bought at GoDaddy)

  2. Sign in to GoDaddy -> DOMAINS -> choose your domain -> Launch (this will take you to the Domain Details)

  3. Click 'DNS Zone File' tab

  4. Remove the CNAME record named 'www' (which points to @)

  5. Click 'Add record' -> CNAME(Alias) -> 'Host' should be www and 'Points to' should be your Heroku address (example supermoo-bil-3411.herokuapp.com). TTL can be 1 hour.

It can take some time for the DNS to propogate. For me it took about 10 minutes.

That's it! supermoo-bil-3411.herokuapp.com will now be under www.example.com :)

Create a naked domain:

A naked domain removes the need to write www in front of your domain name. This can be done by forwarding example.com to www.example.com. This is super easy on GoDaddy:

  1. In the same window as above, click on the 'Settings' tab

  2. Under Forwarding -> Domain -> Click 'Manage' -> then click 'Add Forwarding'

  3. 'Forward to' should be www.example.com (your domain), 'Redirect type' should be '301 (Permanent)', 'Forward settings' should be 'Forward only'

  4. Make sure "Update my nameservers and DNS settings to support this change. (Recommended)" is checked

    That's it! You are done :)

Useful links:

Thanks to Ryan Kazinec for help :)

One of the easiest ways to setup an external domain with Heroku is using this addon: https://addons.heroku.com/zerigo_dns - You simply have to point the dns nameservers to

a.ns.zerigo.net
b.ns.zerigo.net
c.ns.zerigo.net
d.ns.zerigo.net
e.ns.zerigo.net

I am not affiliated with Zerigo DNS - just a happy user. Any yeah it's free for 50,000 queries per month and for $20/month you get unlimited queries.

Hope this helps.