系统环境:ubuntu20.04
一. ###换国内源
1.备份原来的源,将以前的源备份一下,以防以后可以用的。
?cp /etc/apt/sources.list /etc/apt/sources.list.bak
2.打开/etc/apt/sources.list文件,在前面添加如下条目,并保存。
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-backports main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ focal-security main restricted universe multiverse multiverse
3.执行apt-get update 更新源
二.**使用 APT 安装docker**
1.###添加dcoker源的 GPG 密钥。 ?curl -fsSL https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
2.###向 source.list 中添加 Docker 软件源
add-apt-repository "deb [arch=amd64] https://mirrors.ustc.edu.cn/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
3.###安装 Docker CE
apt-get update && apt-get install docker-ce
4.###安装docker-compose:
sudo curl -L "https://github.com/docker/compose/releases/download/1.28.6/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
5.###编写docker-compoes文件并启动
cd /opt? ?(路径任意本文以/opt举例)
vim docker-compose.yml
version: '2' services: ? openvpn: ? ? cap_add: ? ? ?- NET_ADMIN ? ? image: zhangcun1113/openvpn:latest ? ? container_name: openvpn ? ? ports: ? ? ?- "1194:1194/udp" ? ? restart: always ? ? depends_on: ? ? ? - "gui" ? ? volumes: ? ? ?- ./openvpn-data/conf:/etc/openvpn ? ? ?- "/etc/localtime:/etc/localtime:ro" ? ? ?- "/etc/timezone:/etc/timezone:ro" ? gui: ? ? image: zhangcun1113/openvpn-web:latest ? ? container_name: openvpn-web ? ? ports: ? ? ?- "8080:8080/tcp" ? ? restart: always ? ? volumes: ? ? ?- "/etc/localtime:/etc/localtime:ro" ? ? ?- "/etc/timezone:/etc/timezone:ro" ? ? ?- ./openvpn-data/conf:/etc/openvpn ? ? ?- ./openvpn-data/db:/opt/openvpn-gui/db ?
docker-compose up -d
打开http://ip:8080即可进入后台管理界面
默认用户密码 username: admin password: b3secure
6.###将ip改为服务器的外网ip
创建用户证书
点击证书下载并conf改为ovpn??
?
去官网下载客户端连接?
附加删除用户证书办法
vim? del.sh
#!/bin/bash ?? read -t 7 -p "请输入你要删除的用户证书......" user docker exec openvpn-web bash -c "cd /usr/share/easy-rsa/ && source ./vars && ./revoke-full $user"; ?
?
?
|