HOW TO SETUP AWS NETWORK LOAD BALANCER FOR NGINX

T3 is Nginx Plus Loadbalancer

M5 is Backend Servers ( Not handled by us )

Each T3 will be connected to all Backend servers 

In Nginx Upstream is created by all available backend servers

Allocating an Elastic IP Address

The first step is to allocate an Elastic IP address, which becomes the fixed IP address for your AWS NLB. (While using an Elastic IP address is optional, we strongly recommend that you do so. With a dynamic IP address, the AWS NLB might not remain reachable if you reconfigure or restart it.)

  1. Log in to the AWS Management Console for EC2 (https://console.aws.amazon.com/ec2/).
  2. In the left navigation bar, select Elastic IPs, then click either of the  Allocate new address  buttons.
  3. In the Allocate new address window that opens, click the  Allocate  button.
  4. When the message appears indicating that the request for an Elastic IP address succeeded, click the  Close  button.

The new Elastic IP address appears on the Elastic IPs dashboard.

Creating the AWS NLB

  1. In the left navigation bar, select Load Balancers, then click the  Create Load Balancer  button.
  2. In the Select load balancer type window that opens, click the  Create  button in the  Network Load Balancer  panel (the center one).
  3. In the Step 1: Configure Load Balancer window that opens, enter the following values:
    • In the Basic Configuration section:
      • Name – Name of your AWS NLB (aws-nlb-lb in this guide).
      • Scheme – internet-facing.
    • In the Listeners section:
      • Load Balancer Protocol – TCP (the only available option).
      • Load Balancer Port – Port on which your AWS NLB listens for incoming connections. In this guide, and for most web applications, it is port 80.
    • In the Availability Zones section, the zones that host the EC2 instances to which your AWS NLB routes traffic. Click the radio button in the leftmost column of the appropriate row:
  4. When you select an availability zone in the table, a drop‑down menu appears in the Elastic IP column. Select the address you allocated in Allocating an Elastic IP Address .
  5. Click the  Next: Configure Routing  button in the lower‑right corner of the window.

Configuring the AWS NLB Routing Options

In the Step 2: Configure Routing window that opens, you create a target group, which contains the set of EC2 instances across which your AWS NLB load balances traffic (you’ll specify those instances in Registering Instances in the Target Group ).

  1. In the Target group section, select or enter the following values:
    • Target group – New target group
    • Name – Name of the target group (for this guide, aws-nlb-tg)
    • Protocol – TCP (the only available option)
    • Port – The port you specified for the Load Balancer Port field in Step 3 of the previous section (80 in this guide)
    • Target type – instance
  2. In the Health checks section, open the Advanced health check settings subsection and enter the following values:
    • Protocol – Protocol the AWS NLB uses when sending health checks. This guide uses TCP, which means the AWS NLB makes a health check by attempting to open a TCP connection on the port specified in the next field.
    • Port – Port on the target instances to which the AWS NLB sends health checks. In this guide, we’re selecting traffic port to send health checks to the same port as regular traffic.
    • Healthy threshold – Number of consecutive health checks an unhealthy instance must pass to be considered healthy.
    • Unhealthy threshold – Number of consecutive health checks a healthy instance must fail to be considered unhealthy.
    • Timeout – Number of seconds the AWS NLB waits for a response to the health check before considering the instance unhealthy.
    • Interval – Number of seconds between health checks.


3.  If you want to use HTTP‑based health checks, select HTTP or HTTPS in the Protocol field instead of TCP. Two additional fields open (not shown in the screenshot):

  • Path – The path to which the AWS NLB sends a GET request as the health check.
  • Success codes – Range of HTTP response codes the AWS NLB accepts as indicating a successful health check.

        4. Click the  Next: Register Targets  button in the lower‑right corner of the window.

Registering Instances in the Target Group

In the Step 3: Register Targets window that opens, you add instances to the empty target group you created in the previous section. For this guide, we add both of our NGINX Plus load balancer instances.

  1. In the Instances table, click the radio button in the left‑most column for the two NGINX Plus load balancer instances, ngx-plus-1 and nginx-plus-2.
  2. Click the  Add to registered  button above the table. The instances are added to the Registered targets table.
  3. Click the  Next: Review  button in the lower‑right corner of the window.

Launching the AWS NLB

In the Step 4: Review window that opens:

  1. Verify that the settings are correct. If so, click the  Create  button in the lower‑right corner of the window. To change settings, click the  Previous  button to go back to previous screens.
  2. The AWS NLB is provisioned. When the success message appears, click the  Close  button to return to the Load Balancers dashboard.
  3. The Load Balancers dashboard opens. As noted in the previous Load Balancer Creation Status window, it can take a few minutes to provision the AWS NLB. When the value in the State column of the table changes to active, click the radio button in the left‑most column to display details about the AWS NLB.
  4. To verify that the AWS NLB is working correctly, open a new browser window and navigate to the AWS NLB’s public DNS name, which appears in the DNS name field in the Basic Configuration section of the dashboard. [If you copy and paste the DNS name, be sure not to include the parenthesized words at the end, (A Record).]
    The default Welcome to nginx! page indicates that the AWS NLB has successfully forwarded a request to one of the two NGINX Plus instances.
  5. To verify that the NGINX Plus load balancer is working correctly, Stop Nginx Service on Server and see.

Leave a Reply

Your email address will not be published. Required fields are marked *