2
votes

I am using Ngix, uwsgi (to serve my django files) and apache in my webserver.

But when I try to access the django admin page the images arent loading. The ngix log says error 404 ("GET /static/admin/css/base.css/ HTTP/1.1" 404)

Here is my nginx configuration:

    server {
    listen   80;
    server_name www.xyz.com xyz.com;
    access_log /var/log/nginx/xyz.com-access.log;
    error_log /var/log/nginx/xyz.com-error.log;

    location / {
        include        uwsgi_params;
        uwsgi_pass     127.0.0.1:9001;
    }

    location /media {
        root   /srv/www/xyz.com.com.br/application/x;
    }
    location /templates {
        root   /srv/www/xyz.com.com.br/application/x;
    }       


}

The media directory (that contains css, js and imgs) are located in /usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/admin/media/

I tried to give a location to it but I didnt have success...

2

2 Answers

1
votes

Possibly because of the “/” suffix? Does it work if you request http://example.com/static/admin/css/base.css (without the trailing slash)?

Additionally, you don't seem to have the /static URL setup in your nginx config:

location /static {
    root /usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/admin/media/
}
0
votes

Thanks, I was missing "ADMIN_MEDIA_PREFIX = '/srv/www/xyz.com.br/application/X/' " in settings.py

Also I copied /usr/local/lib/python2.6/dist-packages/Django-1.3-py2.6.egg/django/contrib/admin/media/ to /srv/www/xyz.com.br/application/x/static

and did this change in nginx:

    location /static {
         root /srv/www/xyz.com.br/application/x;
    }