1.目录列表(directory listing)

nginx让目录中的文件以列表的形式展现只需要一条指令

autoindex on;

autoindex可以放在location中,只对当前location的目录起作用。你也可以将它放在server指令块则对整个站点都起作用。或者放到http指令块,则对所有站点都生效。

下面是一个简单的例子:

 
1
2
3
4
5
6
7
8
9
10
11
12
{
;
;
;
;
{
;
}
{
;
}
}

2.nginx禁止访问某个目录

跟Apache的Deny from all类似,nginx有deny all指令来实现。

禁止对叫dirdeny目录的访问并返回403 Forbidden,可以使用下面的配置:

 
1
2
3
4
{
;
;
}

相关文章:

  • 2022-03-03
  • 2021-12-01
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
猜你喜欢
  • 2022-01-24
  • 2021-08-15
  • 2021-06-25
  • 2021-12-11
  • 2021-10-13
  • 2021-11-30
  • 2022-12-23
相关资源
相似解决方案