Skip to main content

How to Setup a OpenVPN Server?

· One min read
Xiaohai Huang

Just a simple command

docker run -itd --restart always --cap-add=NET_ADMIN \
-p 1194:1194/udp -p 7070:8080/tcp \
-e HOST_ADDR=$(curl -s https://api.ipify.org) \
-v openvpn_conf:/opt/Dockovpn_data \
--name dockovpn alekslitvinenk/openvpn

Then download the config file from the http://<public-ip>:7070 and then import the config file (client.ovpn) to the vpn client.

Clients:

How to Backup VPN Data

The VPN container uses named volume to store configuration data. So we can use the volume-backup utility to backup data. https://github.com/loomchild/volume-backup.

  1. Backup. The following command will store the vpn data in "$(pwd)/vpn_config_data.tar.bz2".
backup.sh
docker run -v openvpn_conf:/volume \
-v $(pwd):/backup --rm \
loomchild/volume-backup backup vpn_config_data.tar.bz2
  1. Restore. The following command will use "$(pwd)/vpn_config_data.tar.bz2" to populate and override the volume named openvpn_conf.
restore.sh
docker run -v openvpn_conf:/volume \
-v $(pwd):/backup --rm \
loomchild/volume-backup restore -f vpn_config_data # without extension