[Solved]-Serving static files with Nginx + Gunicorn + Django

21👍

You need to create an nginx location block that matches the location of your django STATIC_URL. As you have it configured, nginx is also forwarding requests for static assets to your django application. I’m guessing you are seeing the 404 errors in your django application log? You want nginx to handle these requests, not django.

location /static {
    alias /home/tunde/django-projects/mumu/STATIC/; 
}

Be sure to run the django admin command collectstatic to make sure all the static assets get copied to the STATIC_ROOT directory.

1👍

location / {
    try_files $uri @proxy_to_app;
}

Please change $uri -> $request_uri

location / {
    try_files $request_uri @proxy_to_app;
}

Leave a comment