使用VPS自建zotero同步的WebDAV服务
0 关键流程
a. Edit - Preferences - Sync - (去设置里注册zotero账号,开启同步)
b. 在必备的插件ZotFile 里进行设置!
Tools - ZotFile Preferences - Location of Files - 勾选 Attach stored copy of file(s)
这个很必须,不然附件无法同步
c. 回到 Edit - Preferences - Sync 进行设置,写入正确的地址。
d. 打开zotero移动端 - 也输入和之前相同的地址
博客地址:https://mustvv.com/archives/zoterowebdav 其他地址:https://zhuanlan.zhihu.com/p/484151790
作为初学的记录,应该会有更好的方法。之后学习新技能再记录。
1 WebDAV服务搭建
1.1 准备
服务器一台。这里使用GreenCloud:Debian 11 amd64 x86_64 GNU/Linux。
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf && echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf && sysctl -p && echo finish!
apt update -y && apt upgrade -y && apt install vim sudo tmux ufw git curl wget zip unzip net-tools -y && ufw --force enable && echo finish!
这里用到了ufw来管理暴露的端口,然而在使用docker的话,会存在一些问题。详情:
https://github.com/chaifeng/ufw-docker
https://mustvv.com/archives/dockerinstallhalo 3.6节
ufw关键步骤:
sudo wget -O /usr/local/bin/ufw-docker https://hub.fastgit.xyz/chaifeng/ufw-docker/raw/master/ufw-docker
chmod +x /usr/local/bin/ufw-docker
sudo systemctl restart ufw
ufw-docker install
ufw route allow proto tcp from any to any port 9999
1.2 开始搭建
参考项目来自bytemark/webdav , 但存在一些问题 ,所以使用了其改进版本。
注意使用root权限登录服务器。并进入/root
mkdir -p /root/webdav/
1.3 安装docker 相关
docker: 让项目带上环境打包(镜像)。运维只需要下载发布的镜像,直接运行即可。集装箱思想,每个项目都是一个集装箱。通过隔离机制,将服务器资源运用极致。
docker-compose: 一般是使用 DockerFile、build、run等手动操作单个容器。如果服务多,互相有依赖关系,就会麻烦,故需要Docker Compose 来轻松高效管理容器,定义运行多个容器。
参考:https://docs.docker.com/compose/gettingstarted/
1.3.1 网络连接不稳定
参考:https://get.daocloud.io/
curl -sSL https://get.daocloud.io/docker | sh
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.3.3/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
1.3.2 网络连接稳定
curl -sSL https://get.docker.com/ | sh
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
1.4 建立yaml文件并启动
注意修改 你的域名 your_domains;修改 账户和密码 USERNAME PASSWORD
vim zoteroWebdav.yml
version: '3'
services:
webdav:
image: k3vmcd/webdav
restart: always
ports:
- "9999:443"
environment:
SERVER_NAMES: your_domains
LOCATION: /dav
AUTH_TYPE: Basic
USERNAME: USERNAME
PASSWORD: PASSWORD
SSL_CERT: selfsigned
volumes:
- /root/webdav:/var/lib/dav
docker-compose -f /root/webdav/zoteroWebdav.yml up -d
启动后,同步的数据放在 /root/webdav/data 里
1.5 一些配置
准备: **1.域名解析 2.ssl证书配置和下载 。**可参考华为云、阿里云(证书免费)文档。
配置:参考 在Apache服务器上安装SSL证书
1.5.1 掏出容器里的配置文件
docker cp webdav_webdav_1:/usr/local/apache2 /root/webdav/apache2
修改 /root/webdav/apache2/conf/sites-available/default-ssl.conf 改为以下内容
1.5.2 修改default-ssl.conf内容
修改 your_domains 以及 证书的位置
# default-ssl.conf文件内容
Listen 443
<VirtualHost *:443>
Protocols h2 http/1.1
ServerName your_domians
ServerAlias your_domians
DocumentRoot "/var/www/html/"
<Directory "/var/www/html/">
Require all denied
</Directory>
CustomLog /proc/self/fd/1 combined
ErrorLog /proc/self/fd/2
SSLEngine on
SSLCertificateFile /var/lib/dav/certApache2/your_domians_public.crt
SSLCertificateKeyFile /var/lib/dav/certApache2/your_domians.key
SSLCertificateChainFile /var/lib/dav/certApache2/your_domians_chain.crt
SSLProtocol all -SSLv3
SSLCipherSuite ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA:ECDHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES256-SHA:ECDHE-ECDSA-DES-CBC3-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:DES-CBC3-SHA:!DSS
SSLHonorCipherOrder on
SSLSessionTickets off
</VirtualHost>
1.5.3 复制替换掉容器里conf文件
docker cp /root/webdav/apache2/conf/sites-available/default-ssl.conf webdav_webdav_1:/usr/local/apache2/conf/sites-available/default-ssl.conf
1.5.4 重启与端口
docker restart webdav_webdav_1
ufw route allow proto tcp from any to any port 9999
1.6 zotero里配置
a. Edit - Preferences - Sync - Location of Files - 勾选 Attach stored copy of file(s)
b. url: https://your_domians:9999/dav/zotero/ , zotero 会自动补https:// 与 /zotero/
c. 并填入 username 和 password
d. 点击 Verify Server
e. Download files 选择 at sync time
f.
在必备的插件ZotFile 里进行设置!
Tools - ZotFile Preferences - Location of Files - 勾选 Attach stored copy of file(s)
这个很必须,不然附件无法同步
1.7 一些说明
参考项目来自bytemark/webdav , 但存在一些问题 ,所以使用了其改进版本。
其中一些配置说明:
Environment variables
All environment variables are optional. You probably want to at least specify USERNAME and PASSWORD (or bind mount your own authentication file to /user.passwd ) otherwise nobody will be able to access your WebDAV server!
SERVER_NAMES : Comma-separated list of domains (eg, example.com,www.example.com ). The first is set as the ServerName, and the rest (if any) are set as ServerAlias. The default is localhost .
–> 域名,默认是localhost
LOCATION : The URL path for WebDAV (eg, if set to /webdav then clients should connect to example.com/webdav ). The default is / .
–> 连接时候的URL path,本文设置的是/dav, 默认是 /
AUTH_TYPE : Apache authentication type to use. This can be Basic (best choice for HTTPS) or Digest (best choice for HTTP). The default is Basic .
–> Basic 是https ,尝试使用http但未成功
REALM : Sets AuthName, an identifier that is displayed to clients when they connect. The default is WebDAV .USERNAME : Authenticate with this username (and the password below). This is ignored if you bind mount your own authentication file to /user.passwd .
–> 用户名
PASSWORD : Authenticate with this password (and the username above). This is ignored if you bind mount your own authentication file to /user.passwd .
–> 密码
ANONYMOUS_METHODS : Comma-separated list of HTTP request methods (eg, GET,POST,OPTIONS,PROPFIND ). Clients can use any method you specify here without authentication. Set to ALL to disable authentication. The default is to disallow any anonymous access.SSL_CERT : Set to selfsigned to generate a self-signed certificate and enable Apache’s SSL module. If you specify SERVER_NAMES , the first domain is set as the Common Name.
–> selfsigned 是自签名证书, zotero好像不允许这个,所以做了配置
1.8 ip访问的搭建参考
https://blog.devzeng.com/blog/build-webdav-server-in-docker.html
2 参考项目
https://github.com/BytemarkHosting/docker-webdav
https://hub.docker.com/r/bytemark/webdav
https://hub.docker.com/r/twizzel/webdav
https://hub.docker.com/r/k3vmcd/webdav
https://hub.docker.com/r/derkades/webdav
|