Question
How do I setup multiple Django sites using the One-Click install option for Ubuntu 16.04
I have successfully created the one-click Django droplet and the website works but I am unsure how to add other Django websites.
This is the process I have taken so far:
I copied the default django_project folder in /home/django and renamed it.
I copied the file in etc/nginx/sites-available and created the sym-link in etc/nginx/sites-enabled
I then updated that file with the following:
upstream newsite_app_server {
server unix:/home/django/gunicorn.socket fail_timeout=0;
}
server {
listen 80;
listen [::]:80;
root /usr/share/nginx/html;
index index.html index.htm;
client_max_body_size 4G;
server_name newsite.com www.newsite.com;
keepalive_timeout 5;
# Your Django project's media files - amend as required
location /media {
alias /home/django/newsite/django_project/media;
}
# your Django project's static files - amend as required
location /static {
alias /home/django/newsite/django_project/static;
}
# Proxy the static assests for the Django Admin panel
location /static/admin {
alias /usr/lib/python2.7/dist-packages/django/contrib/admin/static/admin/;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
proxy_buffering off;
proxy_pass http://newsite_app_server;
}
}
- I restarted the server but then received an error about DisallowedHost, so I then added the domain name to the Allowed_Host line in the settings.py file, restarted Nginx and Gunicorn and still got the same error. I tried using the wildcard [’*’] with no luck.
Am I missing something? It seems as though I should create some other instance of gunicorn but I’m not sure.
I tried to follow the instructions for setting up multiple Django sites for Ubuntu 14.04 at the following link but the settings seem a little different compared to version 16.04:
https://www.digitalocean.com/community/questions/setup-multiple-django-websites-on-django-one-click-install-image-vps
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×