Firxiao

记录些有用的东西

WebDAV 配置一例

27 Jan 2021 » linux

iPad笔记软件Notability, 自动备份中云服务速度不太理想, 发现它支持WebDAV. 于是在树莓派上搭建下, 在此记录一下步骤.

系统这里使用了Manjaro-ARM 21.01

第一步: 安装apache

sudo pacman -S apache

第二步: 启用 WebDAV 模块及依赖

/etc/httpd/conf/httpd.conf 找到下面模块及配置去掉注释

# 模块 在LoadModule中
mod_alias, mod_auth_digest, mod_authn_core, mod_authn_file,
mod_authz_core, mod_authz_user, mod_dav, mod_dav_fs,
mod_setenvif
# 配置
Include conf/extra/httpd-dav.conf

第三步: 配置WebDAV

编辑 /etc/httpd/conf/extra/httpd-dav.conf

#
# Distributed authoring and versioning (WebDAV)
#
# Required modules: mod_alias, mod_auth_digest, mod_authn_core, mod_authn_file,
#                   mod_authz_core, mod_authz_user, mod_dav, mod_dav_fs,
#                   mod_setenvif

# The following example gives DAV write access to a directory called
# "uploads" under the ServerRoot directory.
#
# The User/Group specified in httpd.conf needs to have write permissions
# on the directory where the DavLockDB is placed and on any directory where
# "Dav On" is specified.

# 修改锁文件位置至tmp
DavLockDB "/tmp/dblock"

# 指定上传目录, 请注意要赋予httpd用户读写权限
Alias /uploads "/srv/webdav"

# 修改为上传目录
<Directory "/srv/webdav">
    Dav On
    Options Indexes FollowSymLinks
    AuthType Digest
    AuthName DAV-upload
    # You can use the htdigest program to create the password database:
    #   htdigest -c "/etc/httpd/user.passwd" DAV-upload admin
    AuthUserFile "/etc/httpd/user.passwd"
    AuthDigestProvider file

    # Allow universal read-access, but writes are restricted
    # to the admin user.
    <RequireAny>
        Require method GET POST OPTIONS
        Require user admin
    </RequireAny>
</Directory>

#
# The following directives disable redirects on non-GET requests for
# a directory that does not include the trailing slash.  This fixes a 
# problem with several clients that do not appropriately handle 
# redirects for folders with DAV methods.
#
BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully
BrowserMatch "MS FrontPage" redirect-carefully
BrowserMatch "^WebDrive" redirect-carefully
BrowserMatch "^WebDAVFS/1.[01234]" redirect-carefully
BrowserMatch "^gnome-vfs/1.0" redirect-carefully
BrowserMatch "^XML Spy" redirect-carefully
BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
BrowserMatch " Konqueror/4" redirect-carefully

第四步: 创建账号密码

执行下面命令创建用户admin

sudo htdigest -c "/etc/httpd/user.passwd" DAV-upload admin

第五步: 重启服务

sudo systemctl restart httpd

第六步: 测试

可以安装个winscp进行上传测试.