运行反向代理的Elastic Beanstalk上的TLS

时间:2018-09-06 11:55:13

标签: amazon-web-services ssl nginx elastic-beanstalk aws-load-balancer

我想将TLS添加到我的AWS Elastic Beanstalk应用程序。这是一个在nginx代理服务器后面运行的node.js应用。

这是我已完成的步骤

  1. 从Amazon Certificate Manager获取通配符证书。
  2. 在我的EB实例的负载均衡器配置部分中添加证书。

enter image description here

我的nginx配置的相关部分是

files:
  /etc/nginx/conf.d/proxy.conf:
  mode: "000644"
  content: |
    upstream nodejs {
      server 127.0.0.1:8081;
      keepalive 256;
    }

    server {
      listen 8080;

      proxy_set_header X-Forwarded-Proto $scheme;
      if ( $http_x_forwarded_proto != 'https' ) {
        return 301 https://$host$request_uri;
      }

      location / {
        proxy_pass  http://nodejs;
        proxy_http_version 1.1;
        proxy_set_header        Host            $host;
        proxy_set_header        X-Real-IP       $remote_addr;
        proxy_set_header        X-Forwarded-For $proxy_add_x_forwarded_for;
      }
    }

当我尝试使用https访问我的应用程序时,我得到一个408: Request Timed Out

据我了解,要在nginx上启用ssl,我们需要将cert和pem文件一起添加并监听端口443。但是由于我使用的是ACM证书,所以我没有cert和pem文件。 / p>

要使此功能有效,我需要在nginx.conf中添加些什么?

谢谢

1 个答案:

答案 0 :(得分:1)

在负载平衡器侦听器配置中,对于端口443的侦听器,“实例端口”设置应为80