39 lines
880 B
Nginx Configuration File
39 lines
880 B
Nginx Configuration File
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;
|
||
}
|
||
}
|