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 HTTPSHTTPS 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.

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


CAPTCHA Image
Reload Image