加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 运营中心 > Nginx > 正文

nginx autoindex接收403 Forbidden

发布时间:2020-12-13 21:41:06 所属栏目:Nginx 来源:网络整理
导读:我在使用nginx和autoindex时遇到了麻烦. 即使我把它放在网站主机上,它仍然在扔“403-Forbidden at my” location /pics { autoindex on; } 是我的配置 server { listen 80; server_name www.domain.com; access_log /home/www/log/access.log; error_log /ho

我在使用nginx和autoindex时遇到了麻烦.

即使我把它放在网站主机上,它仍然在扔“403-Forbidden at my”

     location /pics {
             autoindex on;              
     }

是我的配置

        server {

        listen   80;
        server_name www.domain.com;

        access_log /home/www/log/access.log;
        error_log /home/www/log/error.log;

        location / {

                    root   /home/www/public/;
                    index  index.html index.php;
                    }

        location    /pics {
                    autoindex on;
                     }
              }

我检查了nginx -v并使用autoindex模块构建.
在这里变得无能为力.

最佳答案
位置/根目录中设置的根目录不适用于位置/图片,因此如果您检查错误日志,您会看到nginx正在寻找/ pics请求的默认根目录.只需删除位置/并在服务器上下文中设置root和index指令:

server {
  root /home/www/public;
  index index.html index.php;

  location /pics {
    autoindex on;
  }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读