如何让nginx显示文件夹目录

简介:

1. 如何让nginx显示文件夹目录

vi /etc/nginx/conf.d/default.conf

添加如下内容:

location / {   
        root /data/www/file                     //指定实际目录绝对路径;   
        autoindex on;                            //开启目录浏览功能;   
        autoindex_exact_size off;            //关闭详细文件大小统计,让文件大小显示MB,GB单位,默认为b;   
        autoindex_localtime on;              //开启以服务器本地时区显示文件修改日期!   
}

不过有个缺点:

693677-20161011111357618-1636937902.png

html文件的抬头写的是Index of /dns/log/

还有一个问题是这里开启的是全局的目录浏览功能,那么如何实现具体目录浏览功能呢?

2. 只打开网站部分目录浏览功能

只打开

http://www.******.com/soft 目录浏览

vi  /usr/local/nginx/conf/nginx.conf   #编辑配置文件,在server {下面添加以下内容:

location /docker {  
	autoindex on;  
	autoindex_exact_size on;  
	autoindex_localtime on;  
	alias   /nitmirror/sync/docker; 
} 

:wq!  #保存,退出

相关文章
|
10月前
|
应用服务中间件 nginx
|
应用服务中间件 nginx
Nginx 服务器中设置禁止访问文件或目录的方法
Nginx 服务器中设置禁止访问文件或目录的方法
|
4天前
|
应用服务中间件 测试技术 API
nginx文件夹内文件解释<一>
nginx文件夹内文件解释<一>
12 1
|
4天前
|
存储 网络协议 应用服务中间件
nginx文件夹内文件解释<六>
nginx文件夹内文件解释<六>
9 3
|
4天前
|
JSON 前端开发 应用服务中间件
nginx文件夹内文件解释<五>
nginx文件夹内文件解释<五>
13 3
|
4天前
|
应用服务中间件 nginx
nginx文件夹内文件解释<四>
nginx文件夹内文件解释<四>
10 3
|
4天前
|
应用服务中间件 nginx
如何通过Nginx配置将请求转发到conf.d目录下的各个配置文件
如何通过Nginx配置将请求转发到conf.d目录下的各个配置文件
21 2
|
4天前
|
应用服务中间件 nginx Ruby
nginx文件夹内文件解释<七>
nginx文件夹内文件解释<七>
9 2
|
4天前
|
应用服务中间件 nginx
nginx文件夹内文件解释<三>
nginx文件夹内文件解释<三>
6 1
|
3天前
|
应用服务中间件 nginx
nginx文件夹内文件解释<八>
nginx文件夹内文件解释<八>
8 0