Hacker News new | past | comments | ask | show | jobs | submit login

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...




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

Search: