【问题标题】:Nginx static files 403 forbiddenNginx 静态文件 403 禁止
【发布时间】:2018-10-13 00:12:09
【问题描述】:

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

这是我的配置中的部分内容:

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

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

操作系统:Centos 7

【问题讨论】:

  • error.log 中有什么内容?
  • 没什么特别的。 2018/10/12 14:39:17 [error] 23590#0: *1 open() "/home/my_user/static/index.html" failed (13: Permission denied), client: &lt;my_ip&gt;, server: _, request: "GET /static/index.html HTTP/1.1", host: "&lt;my_host&gt;"

标签: nginx nginx-config


【解决方案1】:

启用标志

/usr/sbin/setsebool -P httpd_read_user_content true

解决问题。

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

【讨论】:

    猜你喜欢
    • 2013-05-24
    • 2018-02-20
    • 2015-04-25
    • 2019-06-07
    • 2019-04-17
    • 2015-04-28
    • 2022-01-27
    • 2011-10-11
    相关资源
    最近更新 更多