cancel
Showing results for 
Search instead for 
Did you mean: 

force https bedhind aws elb

force https bedhind aws elb

Hi all,

 

Here is my architecture:

client -> DNS(cloudflare) -> AWS ELB -> web server(LNMP)

and i am using Magento2.0.12 with multistore 

 

My goal:

All clients type http://www.domain.com/ will redirect to https://www.domain.com/

 

What have i did:

1. Changed all site url from http://www.domain.com/ to https://www.domain.com/

Therefore, all clients should be redirect to https:/www.domain.com/xxxx when they click any url in magento2

 

2. applied following nginx config:

if ($http_user_agent != "ELB-HealthChecker/1.0") {
   set $redirect "1";
}
if ($http_x_forwarded_proto != "https") {
   set $redirect "${redirect}2";
}
if ($redirect = "12"){
   return 301 https://$host$request_uri;
}

This is the most popular method that suggested in Nginx and all website i have found.

However, https://www.domain.com/us/ and https://www.domain.com/tw/ which are different sites will become 404.

 

Therefore, i wanna ask is there any suggestions i can try?

Thanks a lot! 

 

2 REPLIES 2

Re: force https bedhind aws elb

It should be enough just to change URLs in:

Magento Admin -> Stores -> Configuration -> Web.

 

Here you have Base URLs and Base URLs (Secure).

Be sure that both sections have https:// in front of URLs.

 

And the second thing would be your NGINX configuration. You should modify "location" section by injecting following lines:

 

location ... {
    ...
    fastcgi_param   HTTPS               on;
    fastcgi_param   HTTP_SCHEME         https;
}

 

If this response was helpful to you, consider giving kudos to this post.

If this response solved your problem, click accept as solution to help others solve this.

 

If this response was helpful to you, consider giving kudos to this post.
If this response solved your problem, click accept as solution to help others solve this issue

Re: force https bedhind aws elb

I had to force https on AWS load balancer too, this is how my nginx conf looks:-

 

listen 80; # aws load balancer sends everything through 80

server_name my-site.com;

# force https for aws load balancer
# ELB stores the protocol used between the client
# and the load balancer in the X-Forwarded-Proto request header.
# Check for 'https' and redirect if not
if ($http_x_forwarded_proto != 'https') {
    rewrite ^ https://$server_name$request_uri? permanent;
}