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;
}
}
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.
I found the solution:
After that start the new service and the new socket, in the example gunicorn2.socket, will be created. - service gunicorn2 start Set the nginx conf with the second upstream calling to this new socket -
upstream newsite_app_server { server unix:/home/django/gunicorn.socket2 fail_timeout=0; }
and restart nginx service.
That works for me. Hope to help.
I am having the same issue… Is there any solution?
Thx in advance.