Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
938 views
in Technique[技术] by (71.8m points)

dns - Rails, Heroku and Subdomains. Is my special case scenario feasible?

Here is my scenario:

I have an application that will have to support multiple clients. Each client will be given a subdomain for there service. We will also have a brochure website that doesn't have the application, its just a website about the product and how potential clients can setup an account with us.

Given:

www.mycoolsite.com would point to a brochure app on Heroku. client1.mycoolsite.com, client2.mycoolsite.com and client3.mycoolsite.com would all point to the same SaaS application that could tell the difference between each request and I should be able to handle so they only see their date (i.e. setting a global client_id or something like that)

How do I go about doing this? I haven't done a lot with DNS so I'm pretty clueless about where to start with this.

Thanks.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

No sweat. We do that now, at Heroku. We happen to use Godaddy for the domain registrar, but any DNS control panel will let you do the same thing.

The other explanations I read here are a little general, here are the specifics...

The explanation at heroku is very good, at : http://docs.heroku.com/custom-domains (there's even a very good screencast shows step by step)

the key thing is if your ROOT domain (mycoolsite.com) is at Heroku you want to create THREE "A" records, because they do some fault-tolerant crossover magic. So you'd have an A record for

75.101.163.44
75.101.145.87
174.129.212.2

Now for each subdomain you create a CNAME record

www  -> proxy.heroku.com
client1 -> proxy.heroku.com
client2 -> proxy.heroku.com
client3 -> proxy.heroku.com

NOW on the HEROKu side, you have two apps right? The 'brochure app' and the saas app.

Login, and for each app go to Resources -> Addon -> Get More Addons ->Custom Domains (free)

for the brochure app, add ONE domain: www.mycoolsite.com

for the saas app, add each of the clients, eg:

client1.mycoolsite.com 
client2.mycoolsite.com 
client3.mycoolsite.com

That's it. works like a champ. Have fun.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...