nginx not serving admin static files?

Posted by toto_tico on Server Fault See other posts from Server Fault or by toto_tico
Published on 2012-06-27T23:13:51Z Indexed on 2012/06/29 3:17 UTC
Read the original article Hit count: 474

Filed under:
|

First, I want to clarify that this error is just for the admin static files. This means my problem is specific just to the static files that corresponds to the Django admin. The rest of the static files are working perfect.

Basically my problem is that for some reason I cannot access those admin static files with the ngix server.

It works perfect with the micro server of Django and the collect static is doing its job. This means it is putting the files on the expected place in the static folder.

The urls are correct but I cannot even access the admin static files directly, but the others I can. So, for example,

  1. I am able to access this url (copying it in the browser): myserver.com:8080/static/css/base/base.css

  2. but i am not able to access this other url (copying it in the browser): myserver.com:8080/static/admin/css/admin.css

I also tried to copy the admin/ directory structure into other_admin_directory_name/. Then I can access myserver.com:8080/static/other_admin_directory_name/css/admin.css

Then, it works. So,

  1. I checked permissions and everything is fine.
  2. I tried to change ADMIN_MEDIA_PREFIX = '/static/admin/' to ADMIN_MEDIA_PREFIX = '/static/other_admin_directory_name/', it doesn't work. This a mistery in itself that I am exploring but still no luck.

Finally, and it seems to be an important clue:

I tried to copy the admin/ directory structure into admin_and_then_any_suffix/. Then I cannot access myserver.com:8080/static/admin_and_then_any_suffix//css/admin.css

So, if the name of the directory starts with admin (for example administration or admin2) it doesn't work.

* added thanks to sarnold observation ** the problem seems to be in the nginx configuration file /etc/nginx/sites-available/mysite

location /static/admin {
   alias /home/vl3/.virtualenvs/vl3/lib/python2.7/site-packages/django/contrib/admin/media/;
}

© Server Fault or respective owner

Related posts about django

Related posts about nginx