Skip to content

piwind/docker-zerotier-planet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker ZeroTier Planet

docker 部署Zerotier 的 PLANET 和 controller UI,包含docker镜像和部署脚本

docker镜像地址:https://hub.docker.com/r/piwind/zerotier-planet

About

此项目原始来自于 xubiaolin/docker-zerotier-planet,包含了如下改动:

  • 修改了ztncui(ZeroTier network controller user interface)项目的链接,改为fork的仓库地址:piwind/ztncui
  • 添加了环境变量 BASE_PATH 的支持
  • 修改了手动构建docker镜像的脚本 build.sh
  • 修改了CI的配置,调整为推送任意tag到github上的时候触发构建docker镜像
  • 重写了README.md,并把详细教程放在了论坛中:https://forum.piwind.com/d/37

Feature

  • 该项目剔除了官方服务器,只保留了自定义的 Planet 节点
  • docker镜像支持 Linux/AMD64、Linux/ARM64 架构
  • 一键部署脚本 deploy.sh(安装/卸载/更新/查看信息/重置密码)
  • 镜像内置 ZeroTier 控制面板 ztncui,支持 BASE_PATH 前缀
  • 自动生成并导出 planet 与 moon 配置,内置文件服务提供带 key 的直链下载
  • 可以使用 build.sh 手动构建docker镜像,也可以通过推送tag到github触发 CI流程自动构建docker镜像,并且可以设置github actions的变量 SPEC_ZEROTIER_TAG 来指定构建时候使用的zerotier的版本号而不是使用 latest

Requirements

  • 服务器要有公网ipv4或ipv6
  • 服务器开放对应端口 9994/tcp, 9994/udp(用于zerotier通信), 3443/tcp(控制面板监听端口,反代的话不用开), 3000/tcp(文件服务的监听端口,反代的话不用开)
  • 服务器安装了docker
  • 中国大陆的服务器需要配置 docker镜像加速,或者透明代理

Installation

使用安装脚本

git clone https://github.com/piwind/docker-zerotier-planet.git
cd docker-zerotier-planet
./deploy.sh

之后根据脚本提示操作即可,安装完成会有如下显示:

install-finish

或者使用docker compose

注意点如下:

  • curl -s https://ipv4.icanhazip.com/,可以拿到自己的公网ipv4地址
  • 这里的 ZT_PORT 和对应的映射端口都要一致
  • BASE_PATH就是nginx反向代理的子路径,例如 /console/zerotier

内容如下:

name: zerotier-planet

services:
  zerotier-planet:
    image: piwind/zerotier-planet:latest
    container_name: zerotier-planet
    restart: unless-stopped
    ports:
      - 9994:9994
      - 9994:9994/udp
      - 3443:3443
      - 3000:3000
    volumes:
      - /data/linux/docker_data/zerotier-planet/dist:/app/dist
      - /data/linux/docker_data/zerotier-planet/ztncui:/app/ztncui
      - /data/linux/docker_data/zerotier-planet/one:/var/lib/zerotier-one
      - /data/linux/docker_data/zerotier-planet/config:/app/config
    environment:
      - IP_ADDR4=<ipv4 addr>
      - IP_ADDR6=
      - ZT_PORT=9994
      - API_PORT=3443
      - FILE_SERVER_PORT=3000
      - BASE_PATH=/console/zerotier

Setup

反向代理(以nginx为例)

在nginx配置文件中,添加location块内容如下:

        location /console/zerotier/ {
            proxy_pass http://127.0.0.1:3443/;
            proxy_set_header HOST $host;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
        location /console/zerotier-files/ {
            proxy_pass http://127.0.0.1:3000/;
            proxy_set_header HOST $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

重新加载nginx:

nginx -t
nginx -s reload

配置防火墙(以ubuntu为例)

## 确保目标端口的tcp和udp都是通的(要特别注意ufw-docker在没有给出tcp还是udp的情况下默认是tcp,因此需要写两条)
ufw-docker allow zerotier-planet 9994
ufw-docker allow zerotier-planet 9994/udp

ufw status

ztncui面板配置

  • 首次用默认账号 admin,密码 password 登录,会提示修改密码
  • 顶部 "Add network",输入Network name即可创建,可以得到Network ID
  • Easy setup,可以方便设置此网络的IP范围

记录下常用信息:

planet ip:<ipv4 addr>
controller控制台:https://www.example.com/console/zerotier/
planet下载:https://www.example.com/console/zerotier-files/planet?key=<key>
moon下载:https://www.example.com/console/zerotier-files/<16-bit addr>.moon?key=<key>
Network ID:<16-bit network id>
IP池子:10.11.12.0/24,范围为 10.11.12.101~199

**授权设备操作:**到控制台中授权即可(Authorized勾选、IP assignment分配ip)

Tutorial

参见链接:https://forum.piwind.com/d/37

包含:

  • 如何使用官方PLANET和controller
  • 如何自建PLANET和controller
  • 客户端配置
  • zerotier-cli常用命令
  • 桥接配置
  • 补充说明等

FAQ

Q: 我更换了 IP 需要怎么处理?

重新部署项目。

Q: 管理后台忘记密码怎么办?

执行 deploy.sh,选择重置密码即可

Q: 为什么我的 ZeroTier 传输不稳定?

部分地区可能对 UDP协议 进行了 QoS,可以考虑使用其他方案比如 OpenVPN

TODO

  • 多 planet 支持
  • 【BUG】在member的IP assignment的窗口,在返回的过程当中会重复添加一样的ip
  • 【添加功能】设置只有admin用户才能删除其他用户,用户之间的network可以分离之类的操作,起到一个PLANET能共享给多人使用
  • 缺少了编辑rule的功能(官方的controller上有)
  • 可以添加二维码的功能,方便移动设备扫码填写network id、PLANET等信息
  • 手机版的界面不友好

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published