nginx 开启 autoindex

autoindex 用于文件目录的展示,配置非常简单,但是千万不要暴露敏感信息,官方文档地址 http://nginx.org/en/docs/http/ngx_http_autoindex_module.html。

配置

location /docs {
  index a.html; 
  autoindex on;
  autoindex_exact_size on;
  autoindex_localtime on;
  root /Users/arraybuffer/Desktop/html;
  
  # 目前还不了解原因,这里需要配置一个不存在的路径,否则会直接访问默认文件 index.html
  index not_exist;
}

参考文档

  1. http://nginx.org/en/docs/http/ngx_http_autoindex_module.html
  2. https://blog.csdn.net/qq_34556414/article/details/105947120