Hacker News new | past | comments | ask | show | jobs | submit login
Ask YC: How do you enable users to use their own domains with your application?
28 points by shabda on Aug 2, 2008 | hide | past | favorite | 9 comments
For example, wordpress.com, blogger.com allow you to use your own domains with their application. This proceed as,

1. You create a blog at whatever.blogspot.com

2. You point a CNAME from your domain say mycname.mysite.com to ghs.google.com

3. The dns changes propgate and you can access your blog at mycname.mysite.com

So what can I do to enable users to use their own domains, with my application, which will be on a subdomain on mysite?

[Edit: Layout]




Can't you use a wildcard? I think you can. Just announce *.youdomain.com -> your.IP. Then, you can just use a custom rewrite rule to transform subdomain.domain.tld into www.domain.tld/sub/subdomain or something similar. From there, you're home free to do everything in your preferred language and framework.


Tell users to CNAME their domain to your own and then render pages based on the incoming HTTP "Host" header?

I feel like you've answered the bulk of your question. Are you looking for something more specific?


Thanks a ton. I wanted to confirm "then render pages based on the incoming HTTP "Host" header" part. A few questions for you,

1. So if DNS CNAME cname.theirsite.com is pointed to myserver.mysite.com, the Http requests will come to myserver.com.mysite.com, with Http['host'] as cname.theirsite.com.

2. Where can I read more about how DNS in general and CNAMES in particlular work?


1. Yes. cname.theirsite.com resolves to myserver.com.mysite.com which in turn resolves to an IP address. Browsers will send requests to your server at that IP along with cname.theirsite.com in "Host" header.

2. I'm not totally sure. I would start with wikipedia: http://en.wikipedia.org/wiki/Domain_Name_System

Users will likely ask for help, so you'll probably want to familiarize yourself with the UIs for major DNS providers, especially GoDaddy.

Another gotcha is that CNAMEs can be a little funky for root domains. So something.com will be harder (or impossible) for people to CNAME than foo.something.com depending on their provider. I've been told that CNAMEing the root domain means that all records (like MX) get automatically aliased as well, but I haven't found that to be uniformly true. My guess is that it depends on the DNS software.


1. Since every address gets resolved into IP, the HTTP requests come to your server's IP address. Your web server decides which site to serve based on HOST header.

You'll have to add an entry in your webserver's settings for each CNAME address you want to handle. Alternatively you can add a default entry to handle any address by a middleware. The middleware will have all the logic (by looking up the DB or whatever) about domain mapping.

I did something similar in django i.e. allowed user subdomains on my site. You can read more about it here: http://sharjeel.2scomplement.com/2008/07/24/django-subdomain...

2. There is a good paper on DNS. Infact only one good paper has been written on DNS which is comprehensive and covers all aspects: http://www.cs.toronto.edu/syslab/courses/csc2231/05au/papers...


Not sure that this is going to help anyone, but since we're on the topic of DNS stuff, I thought I'd throw this out there for anyone who wants control of their domains without having to run a DNS server:

I've been immensely happy with EveryDNS ( http://everydns.net ) since I started using it. It's a free, web-based DNS service. You just point your nameservers at their site and you can then manage all of your domains with their interface -- no need to screw around with nameservers anymore.

I now have nearly 500 records for almost 100 domains on there. While the web interface is pretty janky, I can only remember the service itself going down once over the past year.


The only problem with EveryDNS is lack of API or way of making large-scale changes.


I use something similar, dnsmadeeasy.com. API, fail-over, redundancy, crappy UI. I can't ask for more from a DNS host!


Whichever way you do it, you'll need to hook into your domain's master DNS servers. Maybe your DNS server operator has an API (or you need to find one who does), or you run your own DNS server and do it yourself. Operating DNS servers isn't rocket science, and reloading/refreshing the name database is generally a pretty well-supported feature.

If you're letting users point their subdomain at their own IP address or server, you'll probably want to set a relatively low TTL - most dynamic DNS services use 15 minutes - although you should be aware that this will increase the load on your DNS server. If it's just a matter of creating subdomains that point at your servers and dispatching on virtual hosts, you can safely use more usual TTL values.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: