When I was doing some works, there was a requirement to whitelist development machine by IP Address from the United States. Since I was located in one of South East Asia countries, obviously I didn’t have a connection with US IP Address. So it would be reasonable to buy a VPN service for this.
But why buy a VPN service if we could use the existing VPS and set up a VPN server on it?
As you may guess, I already have VPS running for my development needs. So I would like to install the OpenVPN server in it. There are tons of tutorials out there on how to set up a VPN server by yourself. But mostly it’s a long tutorial with a lot of steps like this one.
Usually, these long steps can be simplified by using a container like Docker. So, in this tutorial, I will show you how to install the OpenVPN server quickly by using existing Docker image.
I assume you already have a VPS running by now. If not, you can buy a VPS with affordable price on DigitalOcean. I have one there too, and I would say it’s enough for our needs.
You can use any OS, but for simplicity, I’ll be using Ubuntu.
If you already have a VPS running, next thing you need is to install Docker.
After all of the requirements fulfilled, we can continue to the next step.
There are 3 variables need to be defined.
The first variable is
It is for data volume container.
It’s recommended to use the
ovpn-data- prefix to operate seamlessly with the reference
The second variable is
The value should be a domain name or IP Address.
The final variable is
It’ll be used as a client definition.
You can name it with something memorable, so you’ll be able to notice where you’re being connected.
The following is an example of value for each variable.
Let’s begin by creating
$OVPN_DATA docker volume.
Next step is to initialize the
It will be used to hold the configuration files and certificates.
The container will ask you for a passphrase to protect the private key used by the newly generated certificate authority.
Wait until the initialize process finished.
After the previous process finished, we can start the OpenVPN server process.
Now that we already have OpenVPN service started, we can generate a client certificate without a passphrase to be used on our local machine.
After the certificate created, we can retrieve the client configuration with embedded certificates file.
That’s all I can write today. Hope this quick tutorial useful for you.
- GitHub - kylemanna/docker-openvpn: 🔒 OpenVPN server in a Docker container complete with an EasyRSA PKI CA