Install and Configure a Test Proxy Server in AWS Install and Configure a Test Proxy Server in AWS

Install and Configure a Test Proxy Server in AWS

Maria Scieranska

Objective

Setting up a test proxy server for use with the Vonage Video API SDK.

Applies To

  • Video API SDK
  • Proxy Server

Procedure

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.

Proxy Server Using AWS and Docker

proxy-architecture.png

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

Create EC2 Instances - Ubuntu

First, let's create an EC2 instance.

  1. Go to Services > EC2.
  2. Select Ubuntu OS.
  3. Click Next and select the network options that best applies to you (default VPC).
  4. Scroll down to Advanced Details | User Data field to attach the installation script.
  5. 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
  6. 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
  7. Run the service using the following command:
    sudo docker stack deploy -c docker-compose.yml proxy
  8. 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.

  1. Navigate to Services > EC2 > Load Balancer.
  2. Select Application Load Balancer.
  3. Set a Name, Listener HTTPS, and select your VPC and availability zones.
    lb-step-1.png
  4. The next step is to configure the Certificate and Security Groups. Make sure to add a Security Group with the HTTPS traffic enabled.
  5. Once this is done you should 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.

  1. Select all the instances that you have created.
  2. Add them to the target group.
  3. 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.

  1. Navigate to Services > Route 53.
  2. Select your host zone.
  3. Click Create Record Set and add an A record.
  4. 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.

Additional Information

For more information on how to use this Proxy URL feature in the Client SDKs, see the developer documentation.

If you 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.