DEV Community

Discussion on: Attach SSL to Elastic Load Balancer (ELB) and enable HTTPS

Collapse
 
rynebenson profile image
Ryne Benson • Edited

I commented on another post, but I think it's more accurate to be placed here. Now that we have SSL setup how should we go about forwarding http to https? I was thinking the best place to do that would be the nginx file, but now I'm receiving 502 and 504 errors. I basically updated that .conf file to look something like this:

server {
  listen 80;

  server_name _;

  location / {
    root      /usr/share/nginx/html;

    index     index.html index.htm;

    try_files $uri $uri/ /index.html;
  }

  error_page 500 502 503 504 /50x.html;

  location = /50x.html {
    root /usr/share/nginx/html;
  }

  return 301 https://$host$request_uri;
}
Enter fullscreen mode Exit fullscreen mode

How do you go about forwarding http to https with this setup?

Collapse
 
mubbashir10 profile image
Mubbashir Mustafa

That you need to do within the ELB (AWS Elastic Load Balancer).

Collapse
 
rynebenson profile image
Ryne Benson

Ah i see I just needed to edit the rule to "Redirect to" then "Port": 443. Thank you!