Complete overwrite: Sync with latest UI and WebDAV logic

This commit is contained in:
admin
2026-01-06 09:17:34 +00:00
parent 309dd0378a
commit 9404ed4a12
7 changed files with 248 additions and 888 deletions

View File

@@ -1,38 +1,31 @@
server {
listen 80;
server_name _;
root /var/www/files;
root /var/www/files; # 确认这是你的文件存放目录
charset utf-8;
# 禁用access log以提高性能可选
# access_log off;
location = /_ui_injection.html {
internal;
alias /var/www/autoindex/ui.html;
}
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;
autoindex_exact_size off;
autoindex_localtime on;
add_after_body /_ui_injection.html;
# WebDAV 核心功能
dav_methods PUT DELETE MKCOL COPY MOVE;
create_full_put_path on;
client_max_body_size 0; # 允许大文件上传
dav_access user:rw group:rw all:rw; # 核心:解决权限控制
# 跨域设置
add_header 'Access-Control-Allow-Origin' '*' always;
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE, MKCOL, COPY, MOVE, PROPFIND' always;
add_header 'Access-Control-Allow-Headers' '*' always;
if ($request_method = 'OPTIONS') { return 204; }
}
}