Django gunicorn Nginx setup only showing 404 page
<p>I have setup a Django dev box on a Debian 7 vps following this tutorial</p>

<p><a href="http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/" rel="nofollow">http://michal.karzynski.pl/blog/2013/06/09/django-nginx-gunicorn-virtualenv-supervisor/</a></p>

<p>Everything seems to work correctly but when i try to go to my domain my.site i get a 404 error page from nginx.
If i use remote desktop i can see the django project using localhost or 127.0.0.1:8000 or 8001 if i launch gunicorn directly.
I have scoured google and here for multiple solutions but none seem to get rid of my issue?</p>

<p>Allowed hosts is set to domain with and without www.</p>

<p>What would cause this error?
I just want to be able to browse my.site in my browser and view the django project, which doesnt seem to be working</p>

<p>Can someone give me insight on what may be happening!?
Here are my configs</p>

<p>nginx-error.log</p>

<pre><code>016/01/11 03:17:51 [error] 29962#0: *5 open() "/webapps/license/static/500.html" failed (2: No such file or directory), client: x.x.x.x, server: my.site, request: "GET / HTTP/1.1", upstream: "http://unix:/webapps/license/run/gunicorn.sock:/", host: "www.my.site"
</code></pre>

<p>Django</p>

<pre><code>(license)app_usr@dev2:~/licdb$ python manage.py runserver
Performing system checks...

System check identified no issues (0 silenced).
January 11, 2016 - 19:47:07
Django version 1.9.1, using settings 'licdb.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
</code></pre>

<p>Gunicorn start script</p>

<pre><code>#!/bin/bash

NAME="licdb"                                  # Name of the application
DJANGODIR=/webapps/license/licdb             # Django project directory
SOCKFILE=/webapps/license/licdb/run/gunicorn.sock  # we will communicte using this unix socket
USER=app_usr                                        # the user to run as
GROUP=webapps                                     # the group to run as
NUM_WORKERS=3                                     # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=licdb.settings             # which settings file should Django use
DJANGO_WSGI_MODULE=licdb.wsgi                     # WSGI module name

echo "Starting $NAME as `whoami`"

# Activate the virtual environment

cd $DJANGODIR
source ../bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH

# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR

# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
  --name $NAME \
  --workers $NUM_WORKERS \
  --user=$USER --group=$GROUP \
  --bind=unix:$SOCKFILE \
  --log-level=debug \
  --log-file=-




(license)root@dev2:/webapps/license/bin# ./gunicorn_start
Starting licdb as root
[2016-01-11 03:58:17 +0000] [30278] [DEBUG] Current configuration:
  proxy_protocol: False
  worker_connections: 1000
  statsd_host: None
  max_requests_jitter: 0
  post_fork: &lt;function post_fork at 0x1060de8&gt;
  pythonpath: None
  enable_stdio_inheritance: False
  worker_class: sync
  ssl_version: 3
  suppress_ragged_eofs: True
  syslog: False
  syslog_facility: user
  when_ready: &lt;function when_ready at 0x1060b18&gt;
  pre_fork: &lt;function pre_fork at 0x1060c80&gt;
  cert_reqs: 0
  preload_app: False
  keepalive: 2
  accesslog: None
  group: 999
  graceful_timeout: 30
  do_handshake_on_connect: False
  spew: False
  workers: 3
  proc_name: licdb
  sendfile: None
  pidfile: None
  umask: 0
  on_reload: &lt;function on_reload at 0x10609b0&gt;
  pre_exec: &lt;function pre_exec at 0x1064410&gt;
  worker_tmp_dir: None
  post_worker_init: &lt;function post_worker_init at 0x1060f50&gt;
  limit_request_fields: 100
  on_exit: &lt;function on_exit at 0x1064aa0&gt;
  config: None
  secure_scheme_headers: {'X-FORWARDED-PROTOCOL': 'ssl', 'X-FORWARDED-PROTO': 'https', 'X-FORWARDED-SSL': 'on'}
  proxy_allow_ips: ['127.0.0.1']
  pre_request: &lt;function pre_request at 0x1064578&gt;
  post_request: &lt;function post_request at 0x1064668&gt;
  user: 999
  forwarded_allow_ips: ['127.0.0.1']
  worker_int: &lt;function worker_int at 0x1064140&gt;
  threads: 1
  max_requests: 0
  limit_request_line: 4094
  access_log_format: %(h)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"
  certfile: None
  worker_exit: &lt;function worker_exit at 0x10647d0&gt;
  chdir: /webapps/license/licdb
  paste: None
  default_proc_name: licdb.wsgi:application
  errorlog: -
  loglevel: debug
  logconfig: None
  syslog_addr: udp://localhost:514
  syslog_prefix: None
  daemon: False
  ciphers: TLSv1
  on_starting: &lt;function on_starting at 0x1060848&gt;
  worker_abort: &lt;function worker_abort at 0x10642a8&gt;
  bind: ['unix:/webapps/license/licdb/run/gunicorn.sock']
  raw_env: []
  reload: False
  check_config: False
  limit_request_field_size: 8190
  nworkers_changed: &lt;function nworkers_changed at 0x1064938&gt;
  timeout: 30
  ca_certs: None
  django_settings: None
  tmp_upload_dir: None
  keyfile: None
  backlog: 2048
  logger_class: gunicorn.glogging.Logger
  statsd_prefix:
[2016-01-11 03:58:17 +0000] [30278] [INFO] Starting gunicorn 19.4.5
[2016-01-11 03:58:17 +0000] [30278] [DEBUG] Arbiter booted
[2016-01-11 03:58:17 +0000] [30278] [INFO] Listening at: unix:/webapps/license/licdb/run/gunicorn.sock (30278)
[2016-01-11 03:58:17 +0000] [30278] [INFO] Using worker: sync
[2016-01-11 03:58:17 +0000] [30289] [INFO] Booting worker with pid: 30289
[2016-01-11 03:58:17 +0000] [30294] [INFO] Booting worker with pid: 30294
[2016-01-11 03:58:17 +0000] [30295] [INFO] Booting worker with pid: 30295
[2016-01-11 03:58:17 +0000] [30278] [DEBUG] 3 workers
</code></pre>

<p>nginx sites-available</p>

<pre><code>upstream license_app_server {
  # fail_timeout=0 means we always retry an upstream even if it failed
  # to return a good HTTP response (in case the Unicorn master nukes a
  # single worker for timing out).


  server unix:/webapps/license/run/gunicorn.sock fail_timeout=0;

}


server {

    listen   80;
    server_name my.site;
    client_max_body_size 4G;
    access_log /webapps/license/logs/nginx-access.log;
    error_log /webapps/license/logs/nginx-error.log;

    location /static/ {
        alias   /webapps/license/static/;
    }


    location /media/ {
        alias   /webapps/license/media/;

    }

    location / {
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        # proxy_buffering off;
        # Try to serve static files from nginx, no point in making an
        # *application* server like Unicorn/Rainbows! serve static files.

        if (!-f $request_filename) {
            proxy_pass http://license_app_server;

            break;

        }

    }


    # Error pages
    error_page 500 502 503 504 /500.html;
    location = /500.html {
        root /webapps/license/static/;

    }

}
</code></pre>

<p>Supervisor</p>

<pre><code>(license)root@dev2:/etc/nginx# supervisorctl start license
license: started
(license)root@dev2:/etc/nginx# supervisorctl status license
license                          RUNNING    pid 30223, uptime 0:00:19
(license)root@dev2:/etc/nginx#
</code></pre>

<p>supervisor.conf</p>

<pre><code>[program:license]
command = /webapps/license/bin/gunicorn_start                    ; Command to start app
user = app_usr                                                          ; User to run as
stdout_logfile = /webapps/license/logs/gunicorn_supervisor.log   ; Where to write log messages
redirect_stderr = true                                                ; Save stderr in the same log
environment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8nvironment=LANG=en_US.UTF-8,LC_ALL=en_US.UTF-8a
</code></pre>

<p>Directory structure</p>

<pre><code>|-- license
|   |-- __init__.py
|   |-- __init__.pyc
|   |-- admin.py
|   |-- admin.pyc
|   |-- apps.py
|   |-- migrations
|   |   |-- __init__.py
|   |   `-- __init__.pyc
|   |-- models.py
|   |-- models.pyc
|   |-- tests.py
|   `-- views.py
|-- db.sqlite3
|-- licdb
|   |-- __init__.py
|   |-- __init__.pyc
|   |-- settings.py
|   |-- settings.pyc
|   |-- urls.py
|   |-- urls.pyc
|   |-- wsgi.py
|   `-- wsgi.pyc
|-- licdb.tx
|-- manage.py
`-- run
    `-- gunicorn.sock
</code></pre>