[Docker] Syncthing 免费开源同步工具
Syncthing 是一款连续的文件同步程序,其可以在两台或多台计算机之间实时同步文件。与其他同步工具不同,Syncthing 强调隐私和安全,确保用户的数据始终处于用户的控制之下。它支持所有的现代操作系统,包括 GNU/Linux、Window、Mac OS X, 以及 Android。
Github:https://github.com/syncthing/syncthing
功能与特点
-
开源软件:
- Syncthing是完全开源的,源代码托管在GitHub上,任何人都可以查看、审查和贡献代码。这种透明性增强了用户对软件安全性的信任。
-
去中心化:
- Syncthing采用P2P(点对点)架构,没有中央服务器,所有数据传输直接在设备之间进行。这不仅提高了数据传输速度,还消除了对第三方服务器的依赖。
-
跨平台支持:
- Syncthing支持多种操作系统,包括Windows、macOS、Linux、BSD、Solaris、Android等,能够满足不同用户的需求。
-
安全性:
- 数据在传输过程中使用TLS加密,确保通信的安全性。此外,每个节点都有唯一的设备ID,通过设备ID进行认证和连接,防止未经授权的设备访问。
-
实时同步:
- 文件修改后会立即触发同步操作,实现实时更新。Syncthing能够检测文件的变化,并迅速同步到其他设备上。
-
版本控制:
- Syncthing支持文件版本控制,可以保留多个文件版本,方便用户在需要时恢复到之前的版本。
-
配置灵活:
- Syncthing提供了丰富的配置选项,用户可以根据需要设置同步目录、同步频率、带宽限制等参数,满足不同的使用场景。
-
简单易用:
- 通过一个友好的Web GUI(图形用户界面),用户可以轻松管理和监控同步状态,进行配置修改。
优点
-
隐私保护:
- 因为不依赖于任何中央服务器,用户的数据不会存储在第三方服务器上,完全在用户的掌控之中,极大地保护了隐私。
-
高效的带宽利用:
- Syncthing在同步过程中只传输更改的部分(增量同步),而不是整个文件,从而提高了带宽利用率,节省了传输时间和资源。
-
安全性高:
- 使用TLS加密传输数据,设备之间的通信经过认证,防止中间人攻击和未经授权的访问。
-
无缝集成:
- Syncthing可以在多种操作系统上运行,并且支持多设备同步,用户可以轻松地在家用电脑、工作电脑、手机等多个设备之间同步文件。
-
社区支持:
- 作为开源项目,Syncthing拥有活跃的社区支持,用户可以从社区获得帮助和建议,及时解决使用过程中遇到的问题。
-
定制化:
- 用户可以根据自己的需求进行高度定制,包括选择需要同步的文件夹、设置不同的同步策略和频率、限制带宽使用等。
-
可靠性:
- Syncthing的设计使其在网络断开后能够自动恢复同步操作,并且支持自动解决同步冲突,确保数据的一致性和可靠性。
部署环境
- 系统:Debian
- 域名一个,并解析到服务器
- 安装好 Docker、Docker-compose,见VPS部署
- 安装好 Caddy,反向代理
部署
升级 packages,
apt update -y
安装常用的软件,
apt install wget curl sudo vim git
syncthing
创建安装目录,
mkdir -p /root/data/docker/syncthing
cd /root/data/docker/syncthing
编辑 docker-compose.yml
,
vim docker-compose.yml
---
version: "2.1"
services:
syncthing:
image: lscr.io/linuxserver/syncthing
container_name: syncthing
hostname: syncthing #optional
environment:
- PUID=1000
- PGID=1000
- TZ=Asia/Shanghai
volumes:
- /root/data/docker_data/syncthing/config:/config
- /root/data/docker_data/syncthing/Documents:/Documents
- /root/data/docker_data/syncthing/Media:/Media
ports:
- 8384:8384
- 22000:22000/tcp
- 22000:22000/udp
- 21027:21027/udp
restart: unless-stopped
本文用的 Docker 镜像支持多种架构,如x86-64、arm64和armhf。
架构(Architecture) 标签(Tag) x86-64 amd64-latest arm64 arm64v8-latest armhf arm32v7-latest
启动,
docker-compose up -d
更新
进入 docker-compose.yml
所在的文件夹,
cd /root/data/docker/syncthing
拉取最新的镜像,
docker-compose pull
重新更新当前镜像,
docker-compose up -d
卸载
进入 docker-compose 所在的文件夹,
cd /root/data/docker/syncthing
停止容器,此时不会删除映射到本地的数据,
docker-compose down
完全删除映射到本地的数据,
cd
rm -rf /root/data/docker/syncthing
反向代理
进入目录 /etc/caddy/sites
,创建并编辑 sync.amaranthinking.eu.org.conf
,
# Uncomment this in addition with the import admin_redir statement allow access to the admin interface only from local networks
# (admin_redir) {
# @admin {
# path /admin*
# not remote_ip private_ranges
# }
# redir @admin /
# }
sync.amaranthinking.eu.org {
log {
level INFO
output file /root/data/docker/syncthing/syncthing.log {
roll_size 10MB
roll_keep 10
}
}
# Uncomment this if you want to get a cert via ACME (Let's Encrypt or ZeroSSL).
# tls {$EMAIL}
# Or uncomment this if you're providing your own cert. You would also use this option
# if you're running behind Cloudflare.
# tls {$SSL_CERT_PATH} {$SSL_KEY_PATH}
# This setting may have compatibility issues with some browsers
# (e.g., attachment downloading on Firefox). Try disabling this
# if you encounter issues.
encode gzip
# Uncomment to improve security (WARNING: only use if you understand the implications!)
# If you want to use FIDO2 WebAuthn, set X-Frame-Options to "SAMEORIGIN" or the Browser will block those requests
header {
# Enable HTTP Strict Transport Security (HSTS)
Strict-Transport-Security "max-age=31536000;"
# Enable cross-site filter (XSS) and tell browser to block detected attacks
X-XSS-Protection "1; mode=block"
# Disallow the site to be rendered within a frame (clickjacking protection)
X-Frame-Options "SAMEORIGIN"
# Prevent search engines from indexing (optional)
X-Robots-Tag "none"
# Server name removing
-Server
}
# Uncomment to allow access to the admin interface only from local networks
# import admin_redir
# Proxy everything to Rocket
reverse_proxy 127.0.0.1:8384 {
# Send the true remote IP to Rocket, so that it can put this in the
# log, so that fail2ban can ban the correct IP.
header_up X-Real-IP {remote_host}
}
}
使用教程
文档地址:https://docs.syncthing.net/intro/getting-started.html
本作品采用 知识共享署名-相同方式共享 4.0 国际许可协议 进行许可。
评论已关闭