How do I setup multiple Django sites using the One-Click install option for Ubuntu 16.04

Posted August 2, 2017 6.1k views
NginxPythonDjangoPython FrameworksUbuntu 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:

  1. I copied the default django_project folder in /home/django and renamed it.

  2. I copied the file in etc/nginx/sites-available and created the sym-link in etc/nginx/sites-enabled

  3. 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;

    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;

  1. 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 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:

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.

Submit an Answer
2 answers

I am having the same issue… Is there any solution?

Thx in advance.

I found the solution:

  • I created a new gunicorn service at - /etc/systemd/system/
Description=Gunicorn daemon for Django Project

ExecStart=/usr/bin/gunicorn --name="YOUR PROJECT NAME" --pythonpath=/home/django/"YOUR PROJECT NAME"  --bind unix:/home/django/"New socket: ie: gunicorn2.socket" --config /etc/gunicorn.d/ django_project.wsgi:application


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.