Saransh Mohapatra
Saransh Mohapatra

Reputation: 9636

Subdomain hosting with Django + Nginx +Gunicorn

I am developing a web app using django for server-side. It has clients in android, ios and frontend. I was thinking of using subdomains for differentiating the urls of these clients. The differentiation is due to the fact that responses to urls are different for different clients. I was hoping of being able to do using subdomains like android.example.com, ios.example.com...etc. My subdomains are fixed.

Can you help regarding what approach I should take to achieve this. Some options I have read are

Please help me with the best option and if possible with links to some tutorials as to how to achieve it. Thanks.

Upvotes: 1

Views: 972

Answers (1)

Bernhard Vallant
Bernhard Vallant

Reputation: 50776

"Using the sites framework" is somehow the same as hosting two projects with the same database. If you would use the sites framework you would have seperate instances for each subdomain which share the same code base and data base, but have to differ in one setting in the first place, which is SITE_ID.

If you're able to run multiple instances this for sure has some advantages:

  • You don't need additional processing via a middleware
  • You can easily choose different settings for each site, eg. different template paths, use different middleware etc, even customize urls per project if necessary
  • You're doing already some kind of load-balancing, as you're directing requests to seperate instances, also if one site crashes it shouldn't affect the others

If you can only run one instance I guess your only choice is using something like a middleware, eg. django-mobile then is maybe something to look in as it offers you some good toolset for determining the type of client etc...

But besides that note that it might not always be the best practice to have seperate domains with the same content when it comes to SEO.

Upvotes: 1

Related Questions