How to solve 404 for static files with Django and Nginx?
- by Lucio
I setup a Trusty VM with Django + Nginx (other stuffs too).
The server is working, I get the "Welcome to Django" page. But when I enter to servername/admin it loads the HTML page but fails to load the static content.
And the admin page have this links to static content:
<link rel="stylesheet" type="text/css" href="/static/admin/css/base.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/login.css" />
Both of the CSS files give me 404, as the Nginx log shows:
192.168.56.1 - - [05/Jun/2014:12:04:09 -0300] "GET /admin HTTP/1.1" 301 5 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0"
192.168.56.1 - - [05/Jun/2014:12:04:09 -0300] "GET /admin/ HTTP/1.1" 200 833 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0"
192.168.56.1 - - [05/Jun/2014:12:04:10 -0300] "GET /static/admin/css/base.css HTTP/1.1" 404 142 "http://ubuntu-server/admin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0"
192.168.56.1 - - [05/Jun/2014:12:04:10 -0300] "GET /static/admin/css/login.css HTTP/1.1" 404 142 "http://ubuntu-server/admin/" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:29.0) Gecko/20100101 Firefox/29.0"
I think that the error is on my nginx.conf file, but do not know how to solve it.