重识Nginx - 08 使用ngx_http_autoindex_module实现目录浏览功能

简介: 重识Nginx - 08 使用ngx_http_autoindex_module实现目录浏览功能

20200103193054943.png

ngx_http_autoindex_module

https://nginx.org/en/docs/http/ngx_http_autoindex_module.html


742ed59006234a1b810408d7315723dd.png


配置

Example Configuration


location / {
    autoindex on;
}


autoindex

Syntax: autoindex on | off;
Default:  
autoindex off;
Context:  http, server, location


Enables or disables the directory listing output.

autoindex on; 设置为on目录是可以访问的

autoindex off; 设置为off目录禁止访问,里面具体内容是可以访问的。


autoindex_exact_size


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

Syntax: autoindex_exact_size on | off;
Default:  
autoindex_exact_size on;
Context:  http, server, location


For the HTML format, specifies whether exact file sizes should be output in the directory listing, or rather rounded to kilobytes, megabytes, and gigabytes.


autoindex_localtime


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

Syntax: autoindex_localtime on | off;
Default:  
autoindex_localtime off;
Context:  http, server, location


For the HTML format, specifies whether times in the directory listing should be output in the local time zone or UTC.


autoindex_format

Syntax: autoindex_format html | xml | json | jsonp;
Default:  
autoindex_format html;
Context:  http, server, location
This directive appeared in version 1.7.9.


Sets the format of a directory listing.


When the JSONP format is used, the name of a callback function is set with the callback request argument. If the argument is missing or has an empty value, then the JSON format is used.


实操


602bda0495e34d878fddde2ff08b4faa.png

访问


1988e390450041fdb73673a01382db2a.png

相关文章
|
6月前
|
安全 应用服务中间件 Linux
Debian操作系统如何安装Nginx并开启HTTP2
本指南介绍了在Linux系统中通过源码编译安装Nginx的完整流程。首先更新软件包列表并安装必要的编译依赖,接着下载指定版本的Nginx源码包(如1.24.0),检查文件完整性后解压。随后通过配置脚本指定安装路径与模块(如HTTP SSL模块),执行编译和安装命令。最后创建软链接以便全局调用,并提供启动、停止及重载Nginx的命令,同时提醒注意安全组设置以确保正常访问。
|
9月前
|
数据可视化 关系型数据库 MySQL
ELK实现nginx、mysql、http的日志可视化实验
通过本文的步骤,你可以成功配置ELK(Elasticsearch, Logstash, Kibana)来实现nginx、mysql和http日志的可视化。通过Kibana,你可以直观地查看和分析日志数据,从而更好地监控和管理系统。希望这些步骤能帮助你在实际项目中有效地利用ELK来处理日志数据。
676 90
|
缓存 应用服务中间件 网络安全
Nginx中配置HTTP2协议的方法
Nginx中配置HTTP2协议的方法
904 7
|
10月前
|
应用服务中间件 PHP nginx
当你的nginx服务器和php服务器不在一起的时候,这个nginx 的root目录问题
两个服务器的网站代码目录需要对齐,docker容器里面也是一样
|
11月前
|
缓存 负载均衡 应用服务中间件
Nginx七层(应用层)反向代理:HTTP反向代理proxy_pass篇
通过使用Nginx的反向代理功能,可以有效地提高Web应用的性能、安全性和可扩展性。配置过程中需要注意不同场景下的具体需求,如负载均衡、SSL终止和缓存策略等。正确配置和优化Nginx反向代理可以显著提升系统的整体表现。
1686 20
|
12月前
|
应用服务中间件 Linux 网络安全
nginx安装部署ssl证书,同时支持http与https方式访问
为了使HTTP服务支持HTTPS访问,需生成并安装SSL证书,并确保Nginx支持SSL模块。首先,在`/usr/local/nginx`目录下生成RSA密钥、证书申请文件及自签名证书。接着,确认Nginx已安装SSL模块,若未安装则重新编译Nginx加入该模块。最后,编辑`nginx.conf`配置文件,启用并配置HTTPS服务器部分,指定证书路径和监听端口(如20000),保存后重启Nginx完成部署。
3722 8
|
12月前
|
存储 应用服务中间件 nginx
nginx反向代理bucket目录配置
该配置实现通过Nginx代理访问阿里云OSS存储桶中的图片资源。当用户访问代理域名下的图片URL(如 `http://代理域名/123.png`)时,Nginx会将请求转发到指定的OSS存储桶地址,并重写路径为 `/prod/files/2024/12/12/123.png`。
422 5
|
负载均衡 安全 应用服务中间件
nginx的强大功能和如何使用?
nginx的强大功能和如何使用?
683 2
|
JSON API 开发者
深入解析Python网络编程与Web开发:urllib、requests和http模块的功能、用法及在构建现代网络应用中的关键作用
深入解析Python网络编程与Web开发:urllib、requests和http模块的功能、用法及在构建现代网络应用中的关键作用
161 0