Being secure
Every security minded organization knows the need for a secure manner to access their private networks, but even in this modern “Infrastructure as a Service” world, VPNs often have to be built manually. When they work well, no one knows that they’re there. When there is even the slightest issue though, everyone notices - accessing internal portals takes an appreciable amount of time due to large latency spikes, teams have difficulty interacting on private resources due to flakey connections... it’s not a pretty world. To ensure these issues never arise, VPNs either need to be oversized or they need to be able to autoscale - they must be highly available (HA). Today we’re going to talk about autoscaling Pritunl - our preferred VPN solution at Mixmax.
Pritunl
We love Pritunl at Mixmax - it’s relatively simple to setup and it’s built to be highly available. It also has single sign on, which makes getting users set up with their credentials much easier than with OpenVPN. It’s also more secure than OpenVPN’s alternative, because Pritunl will create temporary, authorized download links for users to retrieve their personal credentials, whereas in normal OpenVPN deployments credentials have to be shared in some manner (via USB, email, etc). Pritunl also has built in auditing of user activity as well as visualization of the load on your deployment.
All of this sounds great, so what’s the problem?
The problem
While deploying an HA Pritunl configuration is much easier than other systems, it’s still a manual process. In addition to that, due to the manual nature of adding new nodes to the cluster, Pritunl can’t easily autoscale out of the box. While this is fine for most users, we wanted a VPN solution that was as hands off as possible. In order to be able to do this, there were a few problems to solve:
- We need to know the correct Mongo URI for the Pritunl node to start up with, otherwise it won’t be able to identify other nodes to coordinate with.
- We need to register the new host as part of our server set that defines the Pritunl nodes, otherwise any new nodes won’t be able to register themselves to accept user traffic.
- We need to disable the Source/Destination check on the EC2 instances, otherwise they would refuse to proxy network traffic.
Good thing we like solving problems!
Getting creative
Let’s walk through how we solved the previous problems in the user data template file that every new Pritunl node starts with.
Bootstrapping the necessary data
Bootstrapping data is a difficult problem, or rather, it’s a difficult problem if you don’t use a secret management system. Here at Mixmax, we use Vault for storing secrets and auditing access to them. As such, we were able to use Vault in order to retrieve three sensitive credentials that each node needs during its initial boot sequence (which we run as the instance’s user-data).
|
Awesome! Now our node knows how to communicate and learn about all other nodes in our deployment.
Registering the host for work
Now that our node is connected to the rest of our deployment, we need to register it as able to accept network traffic. Thankfully Pritunl has an API that will allow us to do this.
|
Perfect, now our host can accept traffic as part of our VPN.
Disabling the source/destination check
Lastly, we need to disable the source/destination check all EC2 instances in AWS start up with by default.
|
Et Voila!
With those three steps you’ve got all you need to be able to setup an autoscaling group in AWS that can register new nodes as you need to scale up and scale down! In the near future, we’re also hoping to open source the Terraform module that we use for this at Mixmax so others can use it as well!
Enjoy working on problems that you can't copy-paste a solution for? Drop us a line.