I want to redirect all the HTTP request to https request on ELB. I have two EC2 instances. I am using nginx for the server. I have tried a rewriting the nginx conf files without any success. I would love some advice on it.
ELB sets X-Forwarded-Proto
header, you can use it to detect if original request was to HTTP and redirect to HTTPS then.
You can try this in your server
conf:
if ($http_x_forwarded_proto = 'http') {
return 301 https://yourdomain.com$request_uri;
}
Take a look at ELB docs.