Setup your VPN server the easy way using docker
In this post, I will show you how to setup your own VPN server in a few simple steps.
## 1. Setup
Step 1 - Create a docker volume to save configuration
docker volume create --name ovpn-data |
Step 2 - Generate config
This step will pull the docker image kylemanna/openvpn:2.3
and run command ovpn_genconfig
. The IP_ADDRESS or DOMAIN is your public ip address, eg udp://vpn.hienhoang.ml
docker run -v ovpn-data:/etc/openvpn --log-driver=none --rm kylemanna/openvpn:2.3 ovpn_genconfig -u udp://{{IP_ADDRESS | DOMAIN}} |
Step 3 - Generate public private key
This step will generate public private key. You must type in 4 to 1023 characters when ask for PEM pass phrase. This will take a few minutes to generate a strong private key.
docker run -v ovpn-data:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn:2.3 ovpn_initpki |
Next command is to generate client key docker run -v ovpn-data:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn:2.3
docker run -v ovpn-data:/etc/openvpn --log-driver=none --rm -it kylemanna/openvpn:2.3 easyrsa build-client-full my_vpn nopass
Generating a 2048 bit RSA private key
...................+++
........+++
writing new private key to '/etc/openvpn/pki/private/my_vpn.key.XXXXpkifIk'
-----
Using configuration from /usr/share/easy-rsa/openssl-1.0.cnf
Step 4 - Export the ovpn file
docker run -v ovpn-data:/etc/openvpn --log-driver=none --rm kylemanna/openvpn:2.3 ovpn_getclient my_vpn > my_vpn.ovpn |
That's it. my_vpn.ovpn
is what you need to connect to this VPN server.
## 2. Usage
Check your VPN server running
docker ps |
Import the .ovpn file using openvpn client
Import profile
-> FILE
Open the .ovpn
file you generated above.
Then click Add
and Connect