代码之家  ›  专栏  ›  技术社区  ›  Ahmed

502 badgateway nginx ALB将http重定向到https

  •  1
  • Ahmed  · 技术社区  · 7 年前

    我在两个nginx实例前面有一个AWS应用程序负载均衡器。应用程序负载平衡器侦听端口80和443。我要做的是将端口80上的所有http流量重定向到443上的https。我创建了两个目标组,其中group1是nginx1,它有两个实例,该组有端口80,而group2是nginx2,它有相同的两个实例,该组有端口443,如图所示 enter image description here

    enter image description here

    然后我将nginx配置为

     server {
        listen       80;
        server_name  www.example.com;
        return 301 https://$host$request_uri;
        }
      server {
        listen       443 ;
        server_name  www.example.com;
        location / {
            root   html;
            index  index.html index.htm;
        }
    }
    

    首先,我的目标是不健康的,即使安全组被配置为监听端口80和443,当我键入 http://www.example.com 在我的浏览器中,我得到502个错误的网关响应

    0 回复  |  直到 7 年前