Nginx不提供静态文件,即使建议配置



我在这里看到这个问题被问了很多次,但不幸的是没有一个答案有效。

基本上我的网站是在Django与Gunicorn和Nginx。Django部分(动态内容)工作正常,但是nginx找不到静态文件。

静态文件位于:

$ ls -l
total 4
drwxrwxr-x 5 django www-data 4096 Oct 19 13:26 findings

我settings.py:

STATIC_URL = '/static/'
STATIC_ROOT = '/home/django/static/findings/'

我的nginx配置:

server {
listen 80;
location = /favicon.ico {
access_log off;
log_not_found off;
}
location = /static {
autoindex on;
alias /home/django/static/findings;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/django/findings-app/run/findings.sock;
}

}

在我的实时网站中,静态url在html源代码中被适当地翻译为:

http://<IP>/static/findings/styles/base.css

由于某些原因,我似乎不能得到正确的语法和nginx只是似乎找不到我的任何静态文件。

谢谢你的帮助!

所以,感谢@LiquidDeath的回答:

它不是location =/static,它应该是location/static,对于收藏夹图标

愚蠢的打字错误:-)