Nginx配置Webdav服务器

1 配置

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
server {
....
location /webdav {
alias /tmp/webdav;
autoindex on;
dav_methods PUT DELETE MKCOL COPY MOVE;
#dav_ext_methods PROPFIND OPTIONS;
dav_access user:rw group:rw all:r;
client_max_body_size 128M;
create_full_put_path on;
client_body_temp_path /tmp/;
auth_basic webdav;
auth_basic_user_file /etc/nginx/.passwords.list;
}
}
server { .... location /webdav { alias /tmp/webdav; autoindex on; dav_methods PUT DELETE MKCOL COPY MOVE; #dav_ext_methods PROPFIND OPTIONS; dav_access user:rw group:rw all:r; client_max_body_size 128M; create_full_put_path on; client_body_temp_path /tmp/; auth_basic webdav; auth_basic_user_file /etc/nginx/.passwords.list; } }
server {
    ....
    location /webdav {
        alias /tmp/webdav;
        autoindex on;
        dav_methods PUT DELETE MKCOL COPY MOVE;
        #dav_ext_methods PROPFIND OPTIONS;
        dav_access user:rw group:rw all:r;

        client_max_body_size 128M;
        create_full_put_path on;
        client_body_temp_path /tmp/;

        auth_basic              webdav;
        auth_basic_user_file    /etc/nginx/.passwords.list;
    }

}

需要注意,alias(即存储目录)必须父目录也有权限..

2 帐号

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo htpasswd -b -c /etc/nginx/.passwords.list user1 pass1
sudo htpasswd -b -c /etc/nginx/.passwords.list user1 pass1
sudo htpasswd -b -c /etc/nginx/.passwords.list user1 pass1

3 测试

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
curl -u user1:pass1 -T './file' 'http://127.0.0.1/webdav/'
curl -u user1:pass1 -T './file' 'http://127.0.0.1/webdav/'
curl -u user1:pass1 -T './file' 'http://127.0.0.1/webdav/'

 

Leave a Reply

Your email address will not be published. Required fields are marked *