0 votes
1 view
in AWS by (19.2k 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.6k 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.


Welcome to Intellipaat Community. Get your technical queries answered by top developers !