yodeveloper
yodeveloper

Reputation: 135

SSL certification not working when I don't use https before my domain name

So I was able to get SSL certificate for my website and it is on AWS but for some reason when I input www.mydomain.com or mydomain.com it still shows unsecured on the browser but when I add https to mydomain.com it shows the secure icon. Please anyone with how to solve this?

Upvotes: 2

Views: 596

Answers (3)

yodeveloper
yodeveloper

Reputation: 135

The above answer work but in addition, if you are using a load balancer in your AWS EC2 instance you can follow this video link to the best explanation and practice. How to redirect HTTP traffic to HTTPS in the EC2 Elastic Load Balancer

Upvotes: 0

Chris Williams
Chris Williams

Reputation: 35258

SSL in web applications is only carried out when your user loads the website using HTTPS. Generally in this situation you would want to perform a redirect (a 302 is more preferable initially than a 301 as it is not permanent in the event of a rollback).

There are a number of ways you can trigger a redirection without having to make any server changes, it all depends on your infrastructure setup.

If the first point of call is CloudFront you can update your viewer protocol policy to Redirect HTTP to HTTPS. CloudFront will redirect any HTTP request before they touch the origin.

If you're using an application load balancer then you can update your listener rule for HTTP to redirect HTTP to HTTPS. As with the above requests would not be forwarded to your host.

Otherwise if you're a Classic Load Balancer, Network Load Balancer or just plain EC2 then it falls to you modifying the configuration of your hosts to do the redirect (remembering to set to a 302).

Below are links for most common web servers:

Once you're happy with the redirect, feel free to set as a 301.

Upvotes: 1

Adiii
Adiii

Reputation: 60114

The reason is the server has no redirection policy, you need to add redirection policy to redirect site from HTTP to HTTPs.

enter image description here

If you are using Application load balancer you can go through below article to set up HTTP to HTTPS redirection.

redirect-http-to-https-using-alb

If you are using Nginx, then you can look into redirect-http-to-https-in-nginx

enter image description here

https-everywhere

Upvotes: 3

Related Questions