2

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.

0

3 Answers 3

1

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

1

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.

3
  • 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 Sep 6, 2009 at 14:35
  • you might want to check out docs.djangoproject.com/en/dev/ref/contrib/sites Sep 6, 2009 at 19:31
  • Django Sites does not do what I am trying to do. Sep 7, 2009 at 2:24
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .