forked from sashgorokhov/docker-nginx-webdav
-
Notifications
You must be signed in to change notification settings - Fork 31
/
webdav.conf
99 lines (82 loc) · 2.28 KB
/
webdav.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
dav_ext_lock_zone zone=a:10m;
server {
#server_name webdav.mashnp.sk;
set $webdav_root "/media/";
auth_basic "Restricted";
auth_basic_user_file /etc/nginx/htpasswd;
dav_ext_lock zone=a;
location / {
root $webdav_root;
error_page 599 = @propfind_handler;
error_page 598 = @delete_handler;
error_page 597 = @copy_move_handler;
open_file_cache off;
access_log /var/log/nginx/webdav_access.log;
error_log /var/log/nginx/webdav_error.log debug;
send_timeout 3600;
client_body_timeout 3600;
keepalive_timeout 3600;
lingering_timeout 3600;
client_max_body_size 10G;
if ($request_method = PROPFIND) {
return 599;
}
if ($request_method = PROPPATCH) { # Unsupported, allways 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>';
}
if ($request_method = MKCOL) { # Microsoft specific handle: add trailing slash.
rewrite ^(.*[^/])$ $1/ break;
}
if ($request_method = DELETE) {
return 598;
}
if ($request_method = COPY) {
return 597;
}
if ($request_method = MOVE) {
return 597;
}
dav_methods PUT MKCOL;
dav_ext_methods OPTIONS LOCK UNLOCK;
create_full_put_path on;
min_delete_depth 0;
dav_access user:rw group:rw all:rw;
autoindex on;
autoindex_exact_size on;
autoindex_localtime on;
if ($request_method = OPTIONS) {
add_header Allow 'OPTIONS, GET, HEAD, POST, PUT, MKCOL, MOVE, COPY, DELETE, PROPFIND, PROPPATCH, LOCK, UNLOCK';
add_header DAV '1, 2';
return 200;
}
}
location @propfind_handler {
internal;
open_file_cache off;
if (!-e $webdav_root/$uri) { # Microsoft specific handle.
return 404;
}
root $webdav_root;
dav_ext_methods PROPFIND;
}
location @delete_handler {
internal;
open_file_cache off;
if (-d $webdav_root/$uri) { # Microsoft specific handle: Add trailing slash to dirs.
rewrite ^(.*[^/])$ $1/ break;
}
root $webdav_root;
dav_methods DELETE;
}
location @copy_move_handler {
internal;
open_file_cache off;
if (-d $webdav_root/$uri) { # Microsoft specific handle: Add trailing slash to dirs.
more_set_input_headers 'Destination: $http_destination/';
rewrite ^(.*[^/])$ $1/ break;
}
root $webdav_root;
dav_methods COPY MOVE;
}
}