如何配置 heroku 应用程序 DNS 到 Godaddy 域?

我已经创建了一个 heroku 应用程序,并希望从 goaddy.com 给它提供域名。

我已经配置了 heroku 提供的所有三个主机,但是现在出现了错误:

Heroku | 没有这样的应用程序

在该主机名下没有配置应用程序。

可能是应用程序所有者重新命名了它,或者你输错了 URL。

我想知道: 有没有其他方法来配置 heroku 应用程序?

更新: 新方法 请使用此链接进行新的方法 。已接受的答案是旧的功能。

141426 次浏览

There are 2 steps you need to perform,

  1. Add the custom domains addon and add the domain your going to use, eg www.mywebsite.example to your application
  2. Go to your domain registrar control panel and set www.mywebsite.example to be a CNAME entry to yourapp.herokuapp.com assuming you are using the CEDAR stack.
  3. There is a third step if you want to use a naked domain, eg mywebsite.example when you would have to add the IP addresses of the Heroku load balancers to your DNS for mywebsite.example

You can read more about this at http://devcenter.heroku.com/articles/custom-domains

At a guess you've missed out the first step perhaps?

Following the announcement of Bamboo's EOL proxy.heroku.com being retired (September 2014) for Bamboo applications so these should also now use the yourapp.herokuapp.com mapping now as well.

I used this videocast to set up my GoDaddy domain with Heroku, and it worked perfectly. Very clear and well explained.

Note: Skip the part about CNAME yourdomain.example. (note the .) and the heroku addons:add "custom domains"

http://blog.heroku.com/archives/2009/10/7/heroku_casts_setting_up_custom_domains/


To summarize the video:

  1. on GoDaddy and create a CNAME with

    Alias Name: www
    Host Name: proxy.heroku.com
    
  2. check that your domain has propagated by typing host www.yourdomain.example on the command line

  3. run heroku domains:add www.yourdomain.example

  4. run heroku domains:add yourdomain.example

It worked for me after these steps. Hope it works for you too!

However, things have changed. Check out this post: Heroku/GoDaddy: send naked domain to www

The trick is to

  1. create a CNAME for www.myapp.example to myapp.heroku.com
  2. create a 301 redirection from myapp.example to www.myapp.example

You can't use the naked domain of your-domain.com if it is not redirected to the www.your-domain.com. Heroku use the www.yourdomain.com which act here as a subdomain. So when you follow the default instruction to use your-domain.com then you will need to assign both of them.

We can actually assign only the naked domain without the www.your-domain.com. Use only your-domain.com when the domain's dns provider (NameServers) support ALIAS or ANAME for the @ Record to example.herokuapp.com without CNAME www.your-domain.com to it.

It will let you to point www.your-domain.com to other hosting separately (independent).

I pointed the non-www to 54.243.64.13 and the www.domain.com to the alias.herokuapp.com and all worked nicely.

Found the IP only after pointing www.domain.com and then running the dig command on the www.domain.com and it showed:

;; ANSWER SECTION:
www.domain.com. 14400  IN      CNAME   aliasat.herokuapp.com.
aliasat.herokuapp.com. 300 IN CNAME us-east-1-a.route.herokuapp.com.
us-east-1-a.route.herokuapp.com. 60 IN  A       54.235.186.37


;; AUTHORITY SECTION:
herokuapp.com.          900     IN      NS      ns-1378.awsdns-44.org.
herokuapp.com.          900     IN      NS      ns-1624.awsdns-11.co.uk.
herokuapp.com.          900     IN      NS      ns-505.awsdns-63.com.
herokuapp.com.          900     IN      NS      ns-662.awsdns-18.net.

May not be ideal but worked.

Yes, many changes at Heroku. If you're using a Heroku dyno for your webserver, you have to find way to alias from one DNS name to another DNS name (since each Heroku DNS endpoint may resolve to many IP addrs to dynamically adjust to request loads).

A CNAME record is for aliasing www.example.com -> www.example.com.herokudns.com.

You can't use CNAME for a naked domain (@), i.e. example.com (unless you find a name server that can do CNAME Flattening - which is what I did).

But really the easiest solution, that can pretty much be taken care of all in your GoDaddy account, is to create a CNAME record that does this: www.example.com -> www.example.com.herokudns.com.

And then create a permanent 301 redirect from example.com to www.example.com.

This requires only one heroku custom domain name configured in your heroku app settings: www.example.com.herokudns.com. @Jonathan Roy talks about this (above) but provides a bad link.

I struggled a lot to resolve it Nothing seemed to work for me.

The steps I followed are mentioned here.

  1. Go to your App settings.

  2. Click on Add domain.

  3. A dialog will open & will ask you to enter the desired domain. (Please add it starting with www for instance - www.abcd.example )

  4. One added click on Next to move to the next dialog.

  5. After adding the domain you will get the DNS target, Now you need to navigate to GoDaddy and follow the following steps.

  6. Navigate to https://dcc.godaddy.com/domains & click on your domain.

  7. Once clicked you will navigate to https://dcc.godaddy.com/control/yourdomain/settings

  8. Scroll down to the bottom you will see Manage DNS.

  9. It will navigate you to DNS settings then add the entry similar to mentioned below and delete all other CNAME records. Here the value of points is your DNS target that you got in the 4th Step.

  10. Then after some time your site should be mapped to the Heroku app URL.