> ## Documentation Index
> Fetch the complete documentation index at: https://help.draftable.com/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS load balancer example for API Self-Hosted

> Set up an example AWS Classic Load Balancer in front of the EC2 instance running Draftable API Self-Hosted v2 (legacy), from network mapping to listeners.

> [!WARNING]
>
> **API Self-Hosted v2 is deprecated.** Existing v2 deployments will continue to run, but v2 will no longer receive feature updates or non-critical fixes. Plan an upgrade to v3: see [Migrating from API Self-Hosted V2 to V3](https://help.draftable.com/hc/en-us/articles/52985002658841-Migrating-from-API-Self-Hosted-V2-to-V3.md).

This guide shows how to setup an example **Classic load balancer** for you EC2 Draftable instance. 

## Before you begin

Ensure you have configured/prepared the following before creating your load balancer

* Ensure your VPC and EC2 instances are prepared. Assistance for [AWS VPC and instance configuration](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-backend-instances.html#set-up-ec2).
* Launch the EC2 instances that you plan to register with your load balancer. Ensure that the security groups for these instances allow HTTP access on port 80.

## Create and set your load balancer type 

**Step 1**

Open the Amazon EC2 console at [https://console.aws.amazon.com/ec2/](https://console.aws.amazon.com/ec2/)

**Step 2**

On the navigation bar, choose a Region for your load balancer. Be sure to select the same Region that you selected for your EC2 instances.

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-82.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=35a4429e581d560eac8d501fcfa200ea)

**Step 3**

On the navigation pane, under **LOAD BALANCING**, choose **Load Balancers**.

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-83.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=0d3cda82eec8ddc8db149c0e496ed5cd)

**Step 4**

Choose **Create Load Balancer**.

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-84.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=c7ff8f5e610ab97ee1a1aaaba9c422e9)

**Step 5**

In this example we are going to choose the **Classic Load Balancer.** Click **Create**.

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-85.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=2310768622dbf1218f9fd9331df9cf12)

## Configure your load balancer 

We now configure the load balancer, this includes information such as a name, a network, and a listener.

A *listener* is a process that checks for connection requests. It is configured with a protocol and a port for front-end (client to load balancer) connections and a protocol and a port for back-end (load balancer to instance) connections. In this tutorial, you configure a listener that accepts HTTP requests on port 80 and sends them to your instances on port 80 using HTTP.

### Basic configuration 

**Step 1**

Type a name for your load balancer.

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-86.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=47b962d512ceefca17647092e5e77432)

**Step 2**

For **Scheme** and **IP address type,** select *Internet-facing* and *IPv4* respectively. If you require different routing please refer to your own use-case for the correct settings. 

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-87.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=8ce1f780e09abfa08f6596bd6cb15f94)

### Network mapping 

There are two components for **Network mapping** which are the **VPC** selection and **Mapping** configuration:

* Select a **VPC** which will align to your target groups. Ensure you select the right **VPC** at this stage as you cannot change the **VPC** after configuring your load balancer.
* For **Mappings**, select at least one available public subnet in the dropdown box. To improve the availability of your load balancer, select more than one public subnet. You can add at most one subnet per Availability Zone.

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-88.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=51fca5b97500442bee0d375a5ca65486)

### Security groups

**Step 1**

On the **security groups** dropdown box, select a security group that fits your security configuration scheme for your load balancer. If you need to create a new security group for you load balancer, select **create new security group** and assign it to this load balancer. 

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-89.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=69cc827bafd1b2c922a96a80a77a58c5)

### Listeners and routing 

A **listener** is a process that checks for connection requests, using the protocol and port you configure. Traffic received by the listener is then routed per your specification. You can specify multiple rules and multiple certificates per listener after the load balancer is created.

**Step 1**

Select a **Protocol, Port** and \*\*Default action/\*\***target group** for each listener. These settings are critical to ensure that traffic routing to your EC2 instance is properly configured to suit your load balancer use case. Ensure that your target groups have been properly configured as to route traffic back to your EC2 instance. 

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-90.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=4a1bac149b91810fa40513e052d046d5)

**Step 2**

You can add more listeners by clicking **add listener.**

If you require assistance on how target groups work, refer to the [AWS documentation](https://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-target-groups.html). 

### Summary and creation 

**Step 1**

Check the **Summary** page and ensure that all the configurations are accurate. 

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-91.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=ab891f81014bd353f58b298f1246e1e8)

**Step 2**

Once you have verified that all information is accurate click **Create load balancer.**

## Verify your load balancer

**Step 1**

Go to the **Load Balancers** page, and select your new load balancer.

**Step 2**

On the **Description** tab, see the **Status** row. 

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-92.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=3fb64a12bb342e405ce5c65366fd06b8)

**Step 3**

After at least one of your EC2 instances is in service, you can test your load balancer. Copy the string from **DNS name** (for example, my-load-balancer-1234567890.us-west-2.elb.amazonaws.com) and paste it into the address field of an internet-connected web browser. If your load balancer is working, you see the default page of your server.

![](https://mintcdn.com/draftable/XirHSA4IUskuCT0o/images/draftable-api-self-hosted/image-93.png?fit=max\&auto=format\&n=XirHSA4IUskuCT0o\&q=85\&s=26e3eac20ce39d4e3ba5688284074554)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.