2
1
Situation
I've setup an NGINX based Webdav server with SSL enabled. When I tried to connect to the server from Windows Explorer, everything works fine until I uploaded a file. Windows Explorer said The destination already has a file named "[filename]", and if click Replace, Windows prompted Can't read from the source file or disk.
After the failure, I refreshed the Windows Explorer and found that a new file with exact same [filename] has been created on Webdav server and it was 0kb (no data).
I've tried connecting with WinSCP and Cyberduck and everything works fine, no issue with upload/download.
Little Workaround
I've checked my NGINX configuration and can't find problem with it. And here's my NGINX configuration.
nginx.conf
worker_processes auto;
error_log /var/log/nginx/error.log;
load_module /usr/lib/nginx/modules/ngx_http_dav_ext_module.so;
events {
worker_connections 1024;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 4096;
include /etc/nginx/mime.types;
default_type application/octet-stream;
include /etc/nginx/conf.d/*.conf;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
location / {
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
}
webdav.conf
server {
listen 6999 ssl http2;
server_name my.domain;
ssl_certificate /path/to/fullchain.pem;
ssl_certificate_key /path/to/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
ssl_session_cache builtin:1000 shared:SSL:10m;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
client_header_timeout 120s;
client_body_timeout 120s;
client_max_body_size 100m;
location / {
# Windows Explorer Workaround
#if (-d $request_filename) { rewrite ^(.*[^/])$ $1/ break; }
#if ($request_method = MKCOL) { rewrite ^(.*[^/])$ $1/ break; }
root /path/to/webdav/folder;
dav_methods PUT DELETE MKCOL COPY MOVE;
dav_ext_methods PROPFIND OPTIONS LOCK UNLOCK;
dav_access user:rw group:rw all:rw;
client_max_body_size 0;
create_full_put_path on;
client_body_temp_path /srv/client-temp;
autoindex on;
auth_basic on;
auth_basic_user_file /etc/nginx/users.list;
allow all;
}
}
I did some google-ing and found this article. However it did't help.
Also, I tried setting my webdav folder permission to 777 and changed owner to nginx, didn't help.
I checked NGINX access log and found this.
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:20:06 +0800] "PUT /config HTTP/2.0" 201 0 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:20:06 +0800] "LOCK /config HTTP/2.0" 405 157 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:20:06 +0800] "PROPFIND /config HTTP/2.0" 207 463 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:20:07 +0800] "PROPFIND /config HTTP/2.0" 207 463 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:20:07 +0800] "PROPFIND /config HTTP/2.0" 207 463 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:20:07 +0800] "PROPFIND /Thumbs.db HTTP/2.0" 404 153 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:20:07 +0800] "PROPFIND /Documents/somefile HTTP/2.0" 207 511 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "PROPFIND /macOS%20Files HTTP/2.0" 207 448 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "PROPFIND /Documents/somefile HTTP/2.0" 207 511 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "PROPFIND /config HTTP/2.0" 207 463 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "PROPFIND /config%20(2) HTTP/2.0" 404 153 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "PROPFIND / HTTP/2.0" 207 424 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "LOCK /config HTTP/2.0" 405 157 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "PROPFIND /config HTTP/2.0" 207 463 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "LOCK /config HTTP/2.0" 405 157 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "PROPFIND /config HTTP/2.0" 207 463 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:21:33 +0800] "LOCK /config HTTP/2.0" 405 157 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:22:52 +0800] "PROPFIND /macOS%20Files HTTP/2.0" 207 448 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:22:52 +0800] "PROPFIND /desktop.ini HTTP/2.0" 404 153 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:22:52 +0800] "PROPFIND / HTTP/2.0" 207 424 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:22:52 +0800] "PROPFIND / HTTP/2.0" 207 2231 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:29:09 +0800] "PROPFIND /macOS%20Files HTTP/2.0" 207 448 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
xxx.xxx.xxx.xxx - username [29/Sep/2019:15:30:38 +0800] "PROPFIND /macOS%20Files HTTP/2.0" 207 448 "-" "Microsoft-WebDAV-MiniRedir/10.0.18362" "-"
No log output in NGINX error log.
Huge thanks for your help!