Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

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.

my dev stack:

Unbuntu 12.04

Django 1.5

Gunicorn is the server.

share|improve this question

closed as off topic by Bryan, Ward, mdpc, Jenny D, Cakemox Jun 7 '13 at 12:46

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.

Wildcard VirtualHost + CNAME

There are two parts to this approach. I will comment on the server side as I am not a programmer.

Apache WildCard VirtualHost

You can configure a wildcard virtual host in Apache by setting the servername or alias to "*".

ServerAlias *

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.


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

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

share|improve this answer

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.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.