配置 Nginx 的目录浏览功能

Nginx 默认是不允许列出整个目录的,需要配置 Nginx 自带的 ngx_http_autoindex_module 模块实现目录浏览功能 。

location / {
    alias /opt/files/;
    
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;
}

autoindex_exact_size off;
默认为on,显示出文件的确切大小,单位是bytes。
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB

autoindex_localtime on;
默认为off,显示的文件时间为GMT时间。
改为on后,显示的文件时间为文件的服务器时间

REFER:
http://nginx.org/en/docs/http/ngx_http_autoindex_module.html
http://www.swiftyper.com/2016/12/08/nginx-autoindex-configuration/

猜你喜欢

转载自www.cnblogs.com/Irving/p/9194800.html
今日推荐