nginx 显示文件目录
2025年1月21日Nginx autoindex
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
gzip on;
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root data;
autoindex on; # 开启功能
autoindex_exact_size off; # 使用更合理的文件大小指示
autoindex_localtime on; # 使用本地时间
charset utf-8, gbk; # 解决中文乱码问题
add_header Cache-Control no-store; # 阻止浏览器缓存数据
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
fancy-index
https://github.com/aperezdc/ngx-fancyindex
需要使用–add-module构建
fancyindex on;
fancyindex_exact_size off;
fancyindex_localtime on;
fancyindex_time_format "%Y-%m-%d %H:%M";
fancyindex_name_length 128; # 修改显示名称长度
charset utf-8, gbk;
add_header Cache-Control no-store;