Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in AWS by (19.1k points)

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.

1 Answer

0 votes
by (44.4k points)

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;

}

For more information, take a look at the official documentation.

AWS ELB

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...