我有django + gunicorn + nginx在192.168.1.81:3000上运行。该Web应用程序不会提供任何静态文件;它会返回一个404错误。这表明nginx虚拟服务器配置文件存在问题。我尝试了几种堆栈溢出解决方案,但都没有成功。 nginx虚拟服务器文件有什么问题?django + gunicorn + nginx 404服务静态文件
upstream app_server {
server unix:/home/pi/door_site/gunicorn.sock fail_timeout=0;
}
server {
listen 80;
server_name 192.168.1.81;
client_max_body_size 4G;
access_log /home/pi/door_site/logs/nginx-access.log;
error_log /home/pi/door_site/logs/nginx-error.log;
location /static/ {
alias /home/pi/door_site/static/;
}
location/{
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
}
}
是的,我已经设置STATIC_ROOT运行'蟒蛇manage.py collectstatic'来填充STATIC_ROOT点 – jkarimi
是教程我跟着该目录。我再次浏览了一遍,看看我是否错过了关于权限的所有内容,而且这一切似乎都是为了顺序。难道不删除默认的nginx配置文件导致了这个问题? – jkarimi
您是否检查了您的nginx日志以查看'/ static /'url实际尝试读取的路径? – henrikstroem