无法通过 https 访问 AWS Elastic Beanstalk Docker 应用程序

AWS Elastic Beanstalk Docker app can't be reached on https

我一直在努力让我的应用在 https 上 运行。它是单个实例、单个容器 docker 应用程序,运行s dart 代码并在 8080 上提供服务。到目前为止,应用程序 运行s 在 http 上完美运行。我没有,也不想要负载均衡器。 我已按照此处的说明进行操作:https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/https-singleinstance-docker.html and here: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-httpredirect.html。我还将它配置为连接到我位于“server.mysite.com”的站点。我收到拒绝连接错误。我对此有点菜鸟,所以如果您需要更多信息,请告诉我。

问题是实例没有在 443 上侦听。所以事实证明,因为我部署在 AWS Linux 2 上,所以有一种不同的方式来配置 https.conf文档让你制作的文件。 这是参考 https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/platforms-linux-extend.html。本质上,我在根目录中创建了一个文件夹(在 .ebextensions 旁边)并添加了一个具有以下路径的文件 .platform/nginx/conf.d/https.conf 以及文档中所需文件的内容,例如.

server {
    listen 443;
    server_name localhost;

    ssl on;
    ssl_certificate /etc/pki/tls/certs/server.crt;
    ssl_certificate_key /etc/pki/tls/certs/server.key;
    ssl_prefer_server_ciphers on;

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