[Django]-Django nginx admin media

4👍

Try the following config:

location /mediaadmin/ {
    alias /opt/python2.6/lib/python2.6/site-packages/django/contrib/admin/media/;
    expires max;
    add_header Cache-Control public;
}

I changed the path to /django/contrib/admin/media/ as I guess our admin media files are in this folder as normal.

Hint: your MEDIA_ROOT and ADMIN_MEDIA_PREFIX sould be absolute.

0👍

I also found that the following line caused a lot of confusion

location ~* ^.+\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|mov) {
            access_log   off;
            expires      30d; 
        }

I commented this out, and changed /mediaadmin/ from root to alias instead.

👤ApPeL

Leave a comment