Skip to main content

how to redirect http request to https in application load balancer at aws

Why we want to do this - Means redirection of HTTP to https or non-www version to https://www version. 

It's really helpful for SEO and the search engine has only one copy of your website. Otherwise, what happen Google/other search engine bots treat your website as a different website.

So I am assuming that you have already had an AWS account and you have a running instance in it and your website already configured on Route 53 if not then you do it by yourself if you have any questions then you can write in the comment box. 

Steps for Redirection of an HTTP request to HTTPS in Application Load Balancer at AWS


  1. Create an SSL certificate or use your own certificate in Certificate manager/IAM (it is required for application load balancer)
  2. Create an application load balancer 
  3. Configure security group (skips if its already open)
  4. Configure port 80 to redirection to 443 
  5. Set new DNS to your Route 53 


  1. First log in to AWS Account and Go to EC2 Instance and > Load Balancer
  2. Click on Create Load Balancer

        Step 3: Now we have to choose - Application Load Balancer and click on Create



        Step 4 Enter the information as per below image 
             You can choose Name - like i chosen - dvo-application-load-balncr
              You have to allow both the port 80 and 443 
                then choose the availability zone          
            Once you done then click on Next Configure security group in bottom


Step 5: Here you can choose your certificate or you can create or you can also import external certificates which you may buy from other companies/websites.


Step 6 : Configure Security group  (Here i have already created by security group and i allowed few ports as per my application requirements.). Then click on next




Step 7: Basically we have our EC2 instance and our Tomcat is running on port 80 so we have kept as it. 

Now click on Register targets

Step 8: Register Targets (means we have to attach our running ec2 instance to this application load balancer and i attached it)



Step 9 Is review of your configuration 

Step 10: If its success like this then your application load balancer is ready. 


Now you can click on close button. 

Now you can see our application load balancer is active. (Actually, I kept a screenshot of another tab like a listener)



But here in Listeners you can see we have port 80 and 443 for https but in 443 we have SSL Certificate but in port 80 http we don't have and its default action is forwarding so instead of forwarding we have to make a change like a redirect. So click on View/edit rules in Rules column for HTTP 80.

It will show like this so we have to edit these rules here 

The first click on Edit pencil icon on top then it will show one more pencil icon near this IF row click on it. 



Now we have to delete this Then click in last one. 





Once you change it will be look like this.

Now we have to just need to update the DNS of this load balancer in Route 53 in a A record set.

and we hare done. 



Comments

Popular posts from this blog

How do I change the time zone of my Amazon RDS database instance?

As we know bydefault time in the format of UTC in mysql.We can set local time zone to our AWS RDS Instance for our application. or any other time zone prefared Cloud Based Website Hosting Service Provider Steps 1: Go to Services and Select RDS Now to change time zone we have to change "Parameter Group" in left side that is associated with DB instance first we can check default Parameter Group for our instance is Parameter group default.mysql5.7  ( in-sync ) like this. So we have to change the time zone in this Parameter Group.  now open that parameter group (default.mysql5.7)  and click on edit parameter. then search for time_zone (because we want to change it.) then we have to change time_zone only by default it is engine-default (that is utc)  we have to select Asia/Calcutta.  More information we can ref.  https://aws.amazon.com/premiumsupport/knowledge-center/rds-change-time-zone/

Amazon EC2 Server Setup & Installing JDK 8 and Tomcat 8, Running on Port 80 & 443 and Redirect Request from port 80 to 8080 and 443 to 8443

Amazon EC2 Server Setup & Installing JDK 8 and Tomcat 8, Running on Port 80 & 443 and Redirect Request from port 80 to 8080 and 443 to 8443. Step 1 : Log in to your aws account by following this link then click on my account and choose option aws management console. Note: I am assuming you created your account with aws and you are ready with you account if you haven’t done then you can check out on google you will get many and it's a straight forward steps if you have still problem while creating an account you can comment in comment box i will also provide tutorial for that. Once you logged in aws management console you are able to see window like this one Note : Before we go ahead we have to select proper reason from right and side. I choose ohio region for this example. Step 2 : Now you have to choose EC2 Server from Services tab on left side top corner then choose EC2 Services from “Compute option ” You will get window like this one and r

Changing the Time Zone on Amazon Linux Ec2 Instance

Amazon Linux instances are set to the UTC (Coordinated Universal Time) time zone by default, but you may wish to change the time on an instance to the local time or to another time zone in your network. Important These procedures are intended for use with Amazon Linux. For more information about other distributions, see their specific documentation. To change the time zone on an instance Identify the time zone to use on the instance. The  /usr/share/zoneinfo  directory contains a hierarchy of time zone data files. Browse the directory structure at that location to find a file for your time zone. [ec2-user ~]$ ls /usr/share/zoneinfo Africa Chile GB Indian Mideast posixrules US America CST6CDT GB-Eire Iran MST PRC UTC Antarctica Cuba GMT iso3166.tab MST7MDT PST8PDT WET Arctic EET GMT0 Israel Navajo right W-SU ... Some of the entries at this location are directo