django : Serving static files through nginx
server_name
must match hostname inlink
/script
URLs. Either declare your configuration as default for this interface:port pair (listen 8000 default
)- Nginx must listen on the interface where your host's IP is bound (seems ok in your case)
I think using root
in location block is incorrect. I use alias
and it works fine, even without re-configuring django.
# django settings.py
MEDIA_URL = '/static/'
# nginx server config
server {
...
location /static {
autoindex on;
alias /opt/aa/webroot/;
}
}
Hope this makes things simpler.