How to host a free VPN with Amazon LightSail

Many of you have undoubtedly heard of Amazon AWS, as they provide many different cloud computing services that are highly scalable. Many blogs and websites use Amazon EC2 as a CDN. But until recently, the AWS user interface was a little daunting for the average user. It assumed a certain level of technical expertise, and you could seemingly break your instance with ease due to the never ending choice of buttons and options. That was until recently.

Amazon recently introduced LightSail, which is an extremely competitive managed virtual private server service. A quick glance at their pricing page shows prices and specs in line with other cloud computer providers such as Digital Ocean, Vultr, and Linode. Currently, you can get three months free on any of their managed plans which means you get a free WireGuard VPN for three months! Here’s how.

Choose Your Region

The first decision you have to make is where to host your VPN. Right now LightSail doesn’t have the largest selection of servers, but in order to maintain fast speeds and low latency I would go State > Time Zone > Country.

Once your instance is up and running, you can ssh in and begin to prepare your instance.


Prepare Your System

In the following, we give examples for Debian-based operating systems using the apt package manager. If you are using an OS with a different package manager (for example, Fedora Linux with the yum package manager), please adapt the commands shown to your specific system.

First, please ensure that your system is up-to-date and has the latest OS kernel installed.

sudo apt-get update
sudo apt-get upgrade

Next, install the Docker runtime, as well has the docker-compose stack. Create a file install-docker.sh with the following contents:

#!/bin/bash

# This file is install-docker.sh

# Set terminal output
set -xe

# Install Docker
curl -fsSL https://get.docker.com -o get-docker.sh
sudo sh get-docker.sh

# Install docker-compose 1.26.2
sudo curl \
 -L "https://github.com/docker/compose/releases/download/1.26.2/docker-compose-$(uname -s)-$(uname -m)" \
 -o /usr/local/bin/docker-compose

sudo chmod +x /usr/local/bin/docker-compose

Then set this file as executable and run it to add the docker and docker-compose commands to your system:

chmod a+x install-docker.sh
./install-docker.sh

The following commands should run successfully and print the version numbers for docker and docker-compose:

docker -v
docker-compose -v

Finally, install the native WireGuard® network protocol and kernel extensions for your OS:

sudo apt-get update
sudo apt-get install -y wireguard wireguard-dkms wireguard-tools

The following command should run successfully and print the version number for wireguard-tools:

wg -v

Now it is time to reboot the host:

sudo reboot now

Continue to: Docker Configuration