Files
auto-index/nginx.conf
2025-12-03 04:15:17 +00:00

39 lines
880 B
Nginx Configuration File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
server {
listen 80;
server_name _;
root /var/www/files;
charset utf-8;
# 禁用access log以提高性能可选
# access_log off;
location / {
# 启用autoindex
autoindex on;
autoindex_exact_size off; # 显示KB/MB而不是字节
autoindex_localtime on; # 使用本地时间
autoindex_format html;
# 注入自定义样式
add_before_body /autoindex-header.html;
add_after_body /autoindex-footer.html;
}
# 提供header文件
location = /autoindex-header.html {
alias /var/www/autoindex/header.html;
}
# 提供footer文件
location = /autoindex-footer.html {
alias /var/www/autoindex/footer.html;
}
# 禁止访问隐藏文件
location ~ /\. {
deny all;
return 404;
}
}