HerokuApps and Multiple Domains
There are some great docs online for figuring out how to setup heroku domains.
https://devcenter.heroku.com/articles/custom-domains as well as others.
The feature I had to get setup was that for every new herokuapp I spun up under my account/clients account it had to make a sub-domain under that SaaS owners zone/domain.
For example the owner wanted all of these apps to show up under freesurvey.com (not really but just an example url) so each one they spun up would be, for example yoursite.freesurvey.com but also later the person who "subscribed" for the product can also use their real domain like www.mysite.com or survey.mysite.com so it would be fully branded under their name as well.
The interface for the owner and the subscriber would allow them to do 2 things. One they could enter the sub-domain they wanted eg "yoursite" as long as it was free to use in the owners domain name spacing eg "freesurvey.com". Just as you see with basecamp or freshbooks. Second they had a field to enter a full domain they wanted to point here as well eg "survey.mysite.com" to quickly setup the subscriber if they were ready to do that. Keeping in mind each site is a new herokuapp which is really a new IP address. And heroku does not suggest the use of this IP address but to use the herokuapp name as I use below.
After clicking save a few things took place.
- A new herokuapp was spun up from the master git branch
- The herokuapp was given a name that is available from heroku, in my case I ran "heroku create --app NAMEHERE1" using a name the script would produce that I am about 99% sure was available at heroku. But at this point it could just use the one heroku gives it and pass it back to the script.
- During the heroku install the zerigo_dns addon was added.
- The script then adds a domain to heroku via the command "heroku domains:add NAMEHERE.freesurvey.com" this automatically submits that domain via the add on "zerigo_dns" so now my DNS records for that domain "freesurvey.com" includes a CNAME to NAMEHERE.freesurvey.com that points to proxy.heroku.com. The benefit here is that I can do this all in the script at the command line and API to setup the herokuapp so it will respond to the this domain, and the DNS so that it knows of this new subdomain and what to do with it.
A Wildcard DNS record for freesurvey.com would not have worked since each record points to the herokoapp which is it's own domain/IP. So NAMEHERE1.herokuapp.com and NAMEHERE2.herokuapp.com are typically a different server and IP. I did not want all of these sites on one server and I wanted to use a Paas provider like heroku for reasons I note here .
- Finally when the client who now uses this site is ready to point it to their own domain/zone they enter into the form "survey.mydomain.com" and this registers with the herokuapp via the command "heroku domains:add survey.mydomain.com" to accept requests from this domain and point it to "NAMEHERE.herokuapp.com".
So now it works for NAMEHERE.freesurvey.com, survey.mydomain.com and of course the name heroku was give to make the app it NAMEHERE.herokuapp.com. Of course the subscriber has to update their records that ONE time to point their CNAME survey.mydomain.com to ideally NAMEHERE.herokuapp.com
This was already setup for the client who owns the survey making SaaS site in this case for example "freesurvey.com" (not really this domain just an example)
So Zerigo was the Name Server provider for this domain. And was linked to heroku account I made for the client.
1This name is made by Time.now.to_i via the ruby script prefixed with a consistent string of characters like freesurvey so I would end up with an App Name like freesurvey1234556789 which I could error check and make another until heroku says that was available. But that name is pretty rare so so far they are always available.