title: gunicorn setup for django channels
body: <p>My django app works fine on local machine as well as on Heroku, however I'm having troubles to deploy it do Digital Ocean Ubuntu 16.04 droplet. Followed <a href="https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-14-04" rel="nofollow noreferrer">this</a> tutorial, app has started but websockets didn't work.
  By running in terminal virtual environment: <code>daphne -b 0.0.0.0 -p 8000 slist.asgi:channel_layer</code>
  and in second terminal window:</p>
  
  <pre><code>./manage.py runworker
  </code></pre>
  
  <p>The app works but only on port 8000. I can't access it on mydomain.com but only on mydomain.com:8000.
  When I close terminal windows the site cannot be accessed.
  What and how needs to be set for the site to run without my terminal windows and without the ':8000'?</p>
  
  <p>My gunicorn.service file:</p>
  
  <pre><code>[Unit]
  Description=gunicorn daemon
  After=network.target
  
  [Service]
  User=kuba1
  Group=www-data
  WorkingDirectory=/home/kuba1/slistproject
  ExecStart=/home/kuba1/slistproject/slistvenv/bin/gunicorn --workers 3 --bind unix:/home/kuba1/slistproject/slistvenv/src/slist.sock slist.wsgi:application
  
  [Install]
  WantedBy=multi-user.target
  </code></pre>
  
  <p>my Nginx settings:</p>
  
  <pre><code>server {
      listen 80;
      server_name server_name fortests.ovh;
      client_max_body_size 20M;
  
      location /static/ {
          root /home/kuba1/slistproject/slistvenv/src;
      }
  
      location / {
  
  
          proxy_pass http://unix:/home/kuba1/slistproject/slistvenv/src/slist.sock;
              proxy_http_version 1.1;
              proxy_set_header Upgrade $http_upgrade;
              proxy_set_header Connection "upgrade";
  
              proxy_redirect     off;
              proxy_set_header   Host $host;
              proxy_set_header   X-Real-IP $remote_addr;
              proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
              proxy_set_header   X-Forwarded-Host $server_name;
  
          }
  
  }
  </code></pre>