Django - 使用 nginx 访问 ec2 ubuntu 服务器中的静态文件时出现 403 错误

问题描述 投票:0回答:1

我使用了nginx默认端口80。成功部署了django应用程序。但访问静态文件时出现 403 错误..我知道这是与权限相关的问题。所以我尝试了所有的方法。但没有什么是锻炼。

授予777权限和www-data用户。我仍然收到权限被拒绝的错误。

file path structure

location /static/ {
        root /home/ubuntu/FunQuiz-backend/FunQuizAPI/staticfiles/;
        autoindex on;
    }
django nginx http-status-code-403 django-staticfiles ubuntu-22.04
1个回答
0
投票

root
更改为
alias

location /static/ {
    alias /home/ubuntu/FunQuiz-backend/FunQuizAPI/staticfiles/;
    autoindex on;
}

将用户更改为

root
ubuntu
 中的 
/etc/nginx/nginx.conf

user    ubuntu;  ## or root if ubuntu also gives permission denied error

重新启动

nginx
以使更改生效。

© www.soinside.com 2019 - 2024. All rights reserved.