0

我正在尝试将 nginx 配置为从目录提供静态文件。并在尝试访问路径 /static/ 时获得 403 Forbidden

这是我的配置中的部分:

user root;
<...>
http {
    <...>
    server {
        <...>
        location /static/
        {
            alias /home/my_user/static/;
            autoindex on;
        }
        <...>
    }
}

我也有 777 递归权限/home/my_user/static/,是的,我在目录中有 index.html。并且仍然收到错误。为什么?

操作系统:Centos 7

4

1 回答 1

1

启用标志

/usr/sbin/setsebool -P httpd_read_user_content true

解决问题。

感谢https://serverfault.com/questions/899187/nginx-static-file-configuration-for-cenotos-7-minimal-installation

于 2018-10-12T16:12:09.420 回答