Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Application Load Balancer : Redirect HTTP requests to HTTPS with nginx

The Application Load Balancer distributes incoming application traffic across multiple targets, such as EC2 instances, in multiple Availability

Zones. This increases the availability of your application. You add one or more listeners to your Load Balancer.

A listener checks for connection requests from clients, using the protocol and port that you configure, and forwards requests to one or more target groups, based on the rules that you define.

Each target group routes requests to one or more registered targets, such as EC2 instances, using the protocol and port number that youspecify.

One of the major drawbacks of the Application Load balancer is redirecting HTTP requests to HTTPS. HTTPS is a more secure technology and has become the standard way of sending web traffic.

So, lets see how we can redirect HTTP to HTTPS in the application load balancer with nginx.

       Before proceeding further, make sure that you have HTTPS rules enabled for services in the HTTPS listener. (Fig. 1 )

Listener configuration (Fig. 1)

Create and configure a redirect backend with nginx :

1. We will have to setup Nginx on one of our ec2 instances with the following configuration:

server {

listen 80 default_server;

listen [::]:80 default_server;

server_name _;

return 301 https://$host$request_uri;

}

2. Later, we will create a target group pointing to this nginx instance (Fig. 2)

Target Group Configuration (Fig. 2)

3. We will then add the target group to the default rule of our HTTP listener (Fig. 3)

Listener Rule (Fig. 3)

4. Once done, we will remove all the other rules from the HTTP listener except the default rule

This is how we can redirect all HTTP requests to HTTPS with nginx.

The post Application Load Balancer : Redirect HTTP requests to HTTPS with nginx appeared first on DevOpsTech Solutions.



This post first appeared on Migrating XEN Virtual Machines To The AWS Cloud, please read the originial post: here

Share the post

Application Load Balancer : Redirect HTTP requests to HTTPS with nginx

×

Subscribe to Migrating Xen Virtual Machines To The Aws Cloud

Get updates delivered right to your inbox!

Thank you for your subscription

×