0

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

这是我完成的步骤

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

在此处输入图像描述

我的 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,我们需要将证书与 pem 文件一起添加并侦听端口 443。但由于我使用的是 ACM 证书,因此我没有证书和 pem 文件。

我想在我的 nginx.conf 中添加什么才能使其正常工作?

谢谢

4

1 回答 1

1

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

于 2018-09-06T19:12:10.523 回答