重定向到 https 无法使用 AWS Elastic Beanstalk

Redirection to https not working using AWS Elastic Beanstalk

我已经使用 AWS Elastic Beanstalk 为我的应用程序创建了一个环境。我已经使用负载均衡器配置启用了 https。我想将流量从 http 重定向到 https。我已经尝试了以下所有方法,但均无效。

1) 我在我的项目根目录中创建了一个 .ebextensions 文件夹,文件名为 https-redirect-php.config.

2)文件的内容是从以下文件粘贴的。 https://raw.githubusercontent.com/awsdocs/elastic-beanstalk-samples/master/configuration-files/aws-provided/security-configuration/https-redirect/php/https-redirect-php.config.

3)我创建了文件夹的 zip 并将其部署在服务器上。

4)我也尝试使用 eb cli 命令 eb deploy 但它不起作用。

请给我任何帮助。非常感谢

一个解决方案是在您的 .ebextensions 目录中添加一个包含以下行的配置文件:

option_settings:
  aws:elbv2:listener:443:
    ListenerEnabled: 'true'
    Protocol: HTTPS

看看Configuring Your Elastic Beanstalk Environment's Load Balancer to Terminate HTTPS

转到 ELASTIC BEANSTALK -> 配置 -> 负载均衡器 -> 规则

在您拥有端口和证书后尝试添加此规则: