forked from TheInsomniac/Nginx-Fancyindex-Theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webdav-patch.conf
49 lines (39 loc) · 1.82 KB
/
webdav-patch.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
##
# /etc/nginx/webdav-patch.conf
# all the code required to deal with non-copliant webdav requests by Windows Explorer and MacOS Finder
##
index _; # do not serve index.html etc.
# https://www.robpeck.com/2020/06/making-webdav-actually-work-on-nginx/#configuring-webdav
# add trailing slash to make new folder
if ($request_method = MKCOL) {
rewrite ^(.*[^/])$ $1/ break;
}
# add trailing slashes when folder is renamed or copied
set $methdest "";
# if (source is folder)
if (-d $request_filename) {
rewrite ^(.*[^/])$ $1/ ;
set $methdest $request_method$http_destination;
}
# if (source is folder AND command is (move or copy) AND target does not end with "/")
if ($methdest ~ ^(MOVE|COPY).*[^/]$) {
more_set_input_headers "Destination: $http_destination/";
}
# add_header G-methdest $methdest always;
# https://github.com/arut/nginx-dav-ext-module/issues/52#issuecomment-598421279
if ($request_method = PROPPATCH) { # Unsupported, always return OK.
add_header Content-Type 'text/xml';
return 207 '<?xml version="1.0"?><a:multistatus xmlns:a="DAV:"><a:response><a:propstat><a:status>HTTP/1.1 200 OK</a:status></a:propstat></a:response></a:multistatus>';
}
# filter garbage from MacOS Finder and Windows Explorer
location ~ "(\.(_.*|DS_Store|Spotlight-V100|TemporaryItems|Trashes|hidden|localized|DAV)$|System Volume Information$)" {
access_log off;
error_log off;
if ($request_method = PUT) {
return 403;
}
return 404;
}
location ~ \.metadata_never_index$ {
return 200 "Don't index this drive, Finder!";
}