I am going to build an album website using Django 1.5. one of the feature I want to provide my members is to use their own domain name.

www.albumn123.com/user/mike

www.mike.com

now, the site is almost ready. but this domain part I am still clueless. I dont think I can do it just in the coding. I believe I have to config something in the server. this is why I post my question here.

Please point me to a right direction, let me know how I should get started. if possible i want to automate this whole process.

Questions on Server Fault are expected to relate to server, networking, or related infrastructure administration within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.
If this question can be reworded to fit the rules in the help center, please edit the question.

This will make this virtual host the default for any on the selected IP address. If you host multiple sites on your server, I recommend you put this virtualhost on its own IP.

CNAME

For the custom domain name, you can have your client enter a CNAME to map their custom domain to your domain.

www.user.com CNAME www.albumn123.com

Application Logic

Your application will then need to take an environment variable or host header and then deliver the correct web site. Also be sure to handle non-existing domains and normalize your URLS (www.domain.com vs. domain.com) to make things easier to manage.

Yes you can do this with RewriteRules, but in my experience it does not scale well and be be cumbersome if you have to re-organize your filesystem.

I'm not familiar with Gunicorn specifically, but if it's anything like the way Apache (and several other servers) works, it should accept requests for all domains that point to it. It's then up to you to detect in code what the requested domain was and handle it accordingly.

For example, in PHP you can use $_SERVER['HTTP_HOST'] to find the domain name requested, and then build your page depending on the domain. You'll have to have a mapping somewhere to link the arbitrary domain names to your users.