gpt4 book ai didi

django - Nginx 目录禁止 403 django

转载 作者:行者123 更新时间:2023-12-04 19:40:34 24 4
gpt4 key购买 nike

我正在尝试在 centos 8 中部署 django。我收到 403 目录禁止错误。我已经申请

chmod 755 var/www/
我仍然收到此错误
我也申请了 sudo chown myusername:psaserv/var/www/vhosts/aaa.com 但我仍然收到此错误。这是我在服务器日志中遇到的错误
2020/10/22 08:15:14 [error] 78481#0: *398 directory index of "/var/www/vhosts/aaa.com/httpdocs/djangoProject/" is forbidden, client: 162.158.167.71, server: aaa.com, request: "GET / HTTP/1.1", host: "aaa.com"
这是我的 nginx 配置文件
#user  nginx;
worker_processes 1;

#error_log /var/log/nginx/error.log;
#error_log /var/log/nginx/error.log notice;
#error_log /var/log/nginx/error.log info;

#pid /var/run/nginx.pid;

include /etc/nginx/modules.conf.d/*.conf;

events {
worker_connections 1024;
}


http {
include mime.types;
default_type application/octet-stream;

#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';

#access_log /var/log/nginx/access.log main;

sendfile on;
#tcp_nopush on;

#keepalive_timeout 0;
keepalive_timeout 65;
#tcp_nodelay on;

#gzip on;
#gzip_disable "MSIE [1-6]\.(?!.*SV1)";

server_tokens off;

include /etc/nginx/conf.d/*.conf;

}

# override global parameters e.g. worker_rlimit_nofile
include /etc/nginx/*global_params;

最佳答案

您可能只需要确保允许您的自定义文档根作为 HTTP 内容提供。为此,请尝试运行:chcon -vR system_u:object_r:httpd_sys_content_t:s0 /var/www/vhosts/aaa.com前几天这个也咬了我=\
仅供引用 - 如果您安装并运行了 SELinux,这可能也是原因。您要么必须经历解决 SELinux 问题的漫长过程,要么禁用 SELinux,要么将文件保存在 /usr/share/nginx/html 中。文件夹。

关于django - Nginx 目录禁止 403 django,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64478165/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com