Forwarding http to https in node.js express app using EBS & ELB environment

前端 未结 2 1391
-上瘾入骨i
-上瘾入骨i 2021-01-02 23:35

I am using the following to redirect all http requests to https requests.

I can see from logs that the header \'x-forwarded-proto\' is never populated and is undefin

2条回答
  •  时光取名叫无心
    2021-01-03 00:16

    You can edit the nginx config file in the EC2 instance. SSH to ec2 instance and follow the following steps

    1. go to /etc/nginx/conf.d
    2. open 00_elastic_beanstalk_proxy.conf sudo vi 00_elastic_beanstalk_proxy.conf
    3. put

      location / { if ($http_x_forwarded_proto != 'https') { rewrite ^ https://$host$request_uri? permanent; } … }

    4. reload nginx sudo /usr/sbin/nginx -s reload

提交回复
热议问题