How to install and configure a test Proxy Server in AWS

How to install and configure a test Proxy Server in AWS

Question

  • How can I test the IP Proxy feature in the Vonage Video API SDK?
  • How can I setup a test Proxy Server for use with the Vonage Video API SDK?

Summary

The IP proxy feature of the Vonage Video API SDK client routes all internet traffic (except for media streams) via your proxy server and is available as an add-on feature.

After following these instructions you will have a Test Proxy URL that you can use to handle all requests from the Video API SDKs in testing environments. This document is not intended to be used as a guideline for installing and setting up a production system.

For more information on how to use this Proxy URL feature in the Client SDKs please see the following page:
https://tokbox.com/developer/guides/proxy-ip/

If you optionally need fine grained control over media streams routing, check the configurable TURN feature, which can be used independently of IP Proxy or together with it:
https://tokbox.com/developer/guides/configurable-turn-servers/

Proxy server using AWS and Docker

proxy-architecture.png

In the above architecture, we can see a few different entities:

Create EC2 Instances - Ubuntu

Firstly, let's create an EC2 instance...

  • Go to `Services > EC2`
  • Select Ubuntu OS
  • Click `Next` and select the Network options that best applies to you (default VPC)
  • Scroll down to Advanced Details | User Data field to attach the installation script (below)

The following script will install Docker in the instance, clone the proxy configuration and run the service automatically.

#!/bin/bash

sudo apt update -y
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
sudo apt update -y
apt-cache policy docker-ce
sudo apt install docker-ce -y
sudo curl -L "https://github.com/docker/compose/releases/download/1.25.5/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
git clone https://gist.github.com/de3d8f46972a83a883e8dc15cc1e0209.git \
&& cp de3d8f46972a83a883e8dc15cc1e0209/docker-compose.yml ./docker-compose.yml
sudo docker swarm init
sudo docker stack deploy -c docker-compose.yml proxy
sudo docker stack services proxy

If you want to manually install Docker or if already have an instance with Docker installed you only need to make sure swarm is initiated. You can then, copy the `docker-compose` file from:

https://gist.github.com/de3d8f46972a83a883e8dc15cc1e0209.git

Run the service using the following command:

sudo docker stack deploy -c docker-compose.yml proxy

You should then repeat this process to create the other EC2 instances.

Create Application Load Balancer

The next step is to create the Elastic Load Balancer on Amazon Web Services.

  • Navigate to Services > EC2 > Load Balancer
  • Select Application Load Balancer
  • Set a name, listener `HTTPS` and select your VPC and availability zones

lb-step-1.png

The next step is to configure the Certificate and Security Groups. Make sure to add a Security Group with the `HTTPS` traffic enabled.

Once this is done you shouls configure the routing, which means where and how the Load Balancer will redirect the traffic to the instances. Configure a new target group and the health checks. It's important to configure the health check to /healthcheck as the Load Balancer will use the endpoint to check the instances status and will redirect traffic only to healthy endpoints.

lb-step-2.png

Finally, it is necessary to register the instances to the target group

  • Select all the instances that you have created
  • Add them to the target group.
  • It will take a few seconds for the Load Balancer to detect the endpoints as it must run the health-checks

lb-step-3.png

Add record on Route 53

The Load balancer running and forwarding the traffic to the registered instances. One additional step is to add an A record that will redirect the traffic from our DNS record to the Load Balancer DNS address.

  • Navigate to Services > Route 53
  • Select your host zone
  • Click "Create Record Set" and add an A record
  • Alias "Yes" and type the DNS record of your Load Balancer (it should autocomplete)

lb-step-4.png

 

 Your Proxy Server should now be reachable and ready to use.

 

Have more questions? Submit a request