Heroku/Cloudflare DNS Settings

Alex Egg,

** UPDATE 2015 ****

The current official way to setup cloudflare for heroku is to simply setup a cname, e.g.: “eggie5” which points to your heroku app url, e.g.: “alexegg.herokuapp.com”. This works b/c cloudflare implemented a non-standard DNS method called “name flattening”. Now all your requests to eggie5.com will be marshaled to heroku. You also need to setup your domain in your heroku app settings too so heroic knows how to route it internally.

END UPDATE


In order to get CloudFlare and heroku to play along nicely - follow these simple steps:

Migrate your old DNS to CloudFlare by following the wizard on their website. All this required me to do was update the nameservers on godaddy's site and add heroku's  ip addrsses as A level records. Ping your heroku url to see:

$ host alexegg.heroku.com
alexegg.heroku.com is an alias for heroku.com.
heroku.com has address 75.101.145.87
heroku.com has address 75.101.163.44
heroku.com has address 50.16.215.196

Add 3 A records, i.e.: @ points to 75.101.145.87 using the CloudFlare interface.

Now when heroku gets a request to their IP they need to know how to route it to the correct app. So your next step is to install the "Custom Domain" add-on and then add your domain names. E.g. in my case eggie5.com and www.eggie5.com

So when a request comes to heroku via your domain name it knows how to route it!

Simple, but I was just confused for a while until I found out about the add-on business. My fault though, they have it documented on their site: http://docs.heroku.com/custom-domains

http://www.cloudflare.com

 

Permalink: heroku-cloudflare-dns-settings

Tags: heroku, dns, cloudflare

Last edited by Alex Egg, 2016-10-05 19:10:53
View Revision History