Home:ALL Converter>Nginx responds 404 for Django app but static files work

Nginx responds 404 for Django app but static files work

Ask Time:2015-12-30T03:29:59         Author:Franco Correa

Json Formatter

I followed this tutorial in order to get my Django app deployed on a DigitalOcean VPS with uWSGI and Nginx. The static files work well but the Django app itself does not. (404 Not Found - nginx/1.9.6)

# Where to look for content (static and media)
root    /srv/www/$host/;

# Allow gzip compression
gzip_types text/css application/json application/x-javascript;
gzip_comp_level 6;
gzip_proxied any;
# Look for files with .gz to serve pre-compressed data
gzip_static on;

server {        
    listen 80;
    # nginx docs recommend try_files over "if"
    location    /   {
        # Try to serve existing files first
        try_files $uri @proxy =404;
    }
    location @proxy {
        # Pass other requests to uWSGI
        uwsgi_pass unix://srv/apps/_/server.sock;
        include uwsgi_params;
    }
}

Author:Franco Correa,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/34517746/nginx-responds-404-for-django-app-but-static-files-work
yy