重识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

相关文章
|
3月前
|
缓存 应用服务中间件 网络安全
Nginx中配置HTTP2协议的方法
Nginx中配置HTTP2协议的方法
227 7
|
29天前
|
缓存 负载均衡 应用服务中间件
Nginx七层(应用层)反向代理:HTTP反向代理proxy_pass篇
通过使用Nginx的反向代理功能,可以有效地提高Web应用的性能、安全性和可扩展性。配置过程中需要注意不同场景下的具体需求,如负载均衡、SSL终止和缓存策略等。正确配置和优化Nginx反向代理可以显著提升系统的整体表现。
139 20
|
2月前
|
应用服务中间件 Linux 网络安全
nginx安装部署ssl证书,同时支持http与https方式访问
为了使HTTP服务支持HTTPS访问,需生成并安装SSL证书,并确保Nginx支持SSL模块。首先,在`/usr/local/nginx`目录下生成RSA密钥、证书申请文件及自签名证书。接着,确认Nginx已安装SSL模块,若未安装则重新编译Nginx加入该模块。最后,编辑`nginx.conf`配置文件,启用并配置HTTPS服务器部分,指定证书路径和监听端口(如20000),保存后重启Nginx完成部署。
656 7
|
2月前
|
存储 应用服务中间件 nginx
nginx反向代理bucket目录配置
该配置实现通过Nginx代理访问阿里云OSS存储桶中的图片资源。当用户访问代理域名下的图片URL(如 `http://代理域名/123.png`)时,Nginx会将请求转发到指定的OSS存储桶地址,并重写路径为 `/prod/files/2024/12/12/123.png`。
99 5
|
5月前
|
JSON 移动开发 监控
快速上手|HTTP 接口功能自动化测试
HTTP接口功能测试对于确保Web应用和H5应用的数据正确性至关重要。这类测试主要针对后台HTTP接口,通过构造不同参数输入值并获取JSON格式的输出结果来进行验证。HTTP协议基于TCP连接,包括请求与响应模式。请求由请求行、消息报头和请求正文组成,响应则包含状态行、消息报头及响应正文。常用的请求方法有GET、POST等,而响应状态码如2xx代表成功。测试过程使用Python语言和pycurl模块调用接口,并通过断言机制比对实际与预期结果,确保功能正确性。
322 3
快速上手|HTTP 接口功能自动化测试
|
4月前
|
负载均衡 安全 应用服务中间件
nginx的强大功能和如何使用?
nginx的强大功能和如何使用?
361 2
|
4月前
|
JSON API 开发者
深入解析Python网络编程与Web开发:urllib、requests和http模块的功能、用法及在构建现代网络应用中的关键作用
深入解析Python网络编程与Web开发:urllib、requests和http模块的功能、用法及在构建现代网络应用中的关键作用
38 0
|
6月前
|
JavaScript 应用服务中间件 PHP
nginx server 禁止特定目录下的某类文件访问
【8月更文挑战第26天】这段Nginx配置代码旨在保护`/uploads/`目录下的文件,禁止执行任何`.php`, `.html`, `.htm`, 或 `.js`等潜在有害文件,即便被访问也无法运行。取而代之的是重定向到首页。为了实现这一设置,用户需要定位到对应子域名的`.conf`配置文件中进行相应修改。若网站支持多个访问域名,则需确保在正确的`.conf`文件中实施此配置。
135 1
|
6月前
|
应用服务中间件 Linux nginx
【Azure 应用服务】App Service For Container 配置Nginx,设置/home/site/wwwroot/目录为启动目录,并配置反向代理
【Azure 应用服务】App Service For Container 配置Nginx,设置/home/site/wwwroot/目录为启动目录,并配置反向代理
|
6月前
|
缓存 负载均衡 安全
介绍一下Nginx的反向代理功能吧
【8月更文挑战第22天】介绍一下Nginx的反向代理功能吧
135 0