Django fails to find static files served by nginx

Posted by Simon on Server Fault See other posts from Server Fault or by Simon
Published on 2014-06-09T02:09:04Z Indexed on 2014/06/09 3:27 UTC
Read the original article Hit count: 206

Filed under:
|
|

I know this is a really noobish question but I can't find any solution despite finding the problem trivial.

I have a django application deployed with gunicorn. The static files are served by the nginx server with the following url : myserver.com/static/admin/css/base.css. However, my django application keep looking for the static files at myserver.com:8001/static/admin/css/base.css and is obviously failing (404).

I don't know how to fix this. Is it a django or an nginx problem ? Here is my nginx configuration file :

server {
    server_name myserver.com;

    access_log off;

    location /static/ {
        alias /home/myproject/static/;
    }

    location / {
        proxy_pass http://127.0.0.1:8001;
        proxy_set_header X-Forwarded-Host $server_name;
        proxy_set_header X-Real-IP $remote_addr;
        add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
    }
}

Thanks for the help !

© Server Fault or respective owner

Related posts about nginx

Related posts about django