Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am using Nginx as a front end web server redirecting Python requests to Apache + mod_wsgi. Everything with that is working fine. I have one Django project running and I want to setup subdomains for a few of my project apps.

Proposed structure:

/www/project/ -

-->/admin/ - admin.domain.com

-->/www/ - www.domain.com

-->/common_data/ - no subdomain

--> etc

Where is this setup done? Apache or is it done within Django? Is an Apache rewrite rule the best way to do this? I would prefer to maintain urls in the browser window. ie http://domain.com/admin/filebrowser/browse/ -> http://admin.domain.com/filebrowser/browse/.

Any advice would be appreciated. Thanks

PS: I have seen the following links: http://www.djangosnippets.org/snippets/1119/, http://sharjeel.2scomplement.com/2008/07/24/django-subdomains/, http://www.rossp.org/blog/2007/apr/28/using-subdomains-django/ but they dont appear to be doing the same thing.

share|improve this question
add comment

3 Answers 3

Set up multiple <VirtualHost>s in Apache, and point each one to a different DocumentRoot.

share|improve this answer
add comment

I'm currently doing this on my VPS. It's kinda a three step process:

  1. CNAME for my subdomain, this is done in whatever you use to manage your DNS stuff
  2. Virtual host for Ngnix
  3. Virtual host for Apache2

This post was pretty helpful to me: The Django and Ubuntu Intrepid Almanac.

Your DNS entry should look like this:

sub.domain.com. 3600 IN CNAME domain.com.

In the /etc/nginx/sites-available directory:

  • domain.com
  • sub.domain.com

In the /etc/apache2/sites-available directory:

  • domain.com
  • sub.domain.com

Don't forget to add a symbolic link for each of the corresponding sites-enabled directory.

share|improve this answer
    
I have gotten this far but am unsure about the setup of the single Django project to multiple subdomains. Your saying I can have a single Django project, with multiple applications which have their own subdomain? I must need to have a closer look at the link you posted. Thanks –  Mark Stahler Sep 6 '09 at 14:35
    
you might want to check out docs.djangoproject.com/en/dev/ref/contrib/sites –  imjoevasquez Sep 6 '09 at 19:31
    
Django Sites does not do what I am trying to do. –  Mark Stahler Sep 7 '09 at 2:24
add comment
up vote 0 down vote accepted

I have found the solution and it is working quite well. There are a few problems however as some reusable apps (such as django-debug-toobar) have problems with media file paths in the templates. Ofcourse you can modify them to work manually.

Django Multihost Configuration

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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