Back
I want to redirect all the HTTP request to https request on elb. I have 2 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.
You can use ELB’s X-Forwarded-Proto header to detect if the original request was redirected from HTTP to HTTPS.
You can type this in your server configuration
if ($http_x_forwarded_proto = 'http') { return 301 https://domainname.com$request_uri;}
if ($http_x_forwarded_proto = 'http') {
return 301 https://domainname.com$request_uri;
}
For more information, take a look at the official documentation.
AWS ELB
Learn how we helped 50,000+ professionals like you !
31k questions
32.8k answers
501 comments
693 users