简体   繁体   English

使用 AWS Elastic Beanstalk 重定向到 https 不起作用

[英]Redirection to https not working using AWS Elastic Beanstalk

I have created a environment for my application using AWS Elastic Beanstalk.我已经使用 AWS Elastic Beanstalk 为我的应用程序创建了一个环境。 I have enabled https using the load balancer configuration.我已经使用负载均衡器配置启用了 https。 I want to redirect traffic from http to https.我想将流量从 http 重定向到 https。 I have tried all of the following method but it is not working.我已经尝试了以下所有方法,但它不起作用。

1) I created a .ebextensions folder in my project root directory with the file name as https-redirect-php.config. 1) 我在我的项目根目录中创建了一个 .ebextensions 文件夹,文件名为 https-redirect-php.config。

2)The content of the file was pasted from the following file. 2) 文件内容是从以下文件粘贴过来的。 https://raw.githubusercontent.com/awsdocs/elastic-beanstalk-samples/master/configuration-files/aws-provided/security-configuration/https-redirect/php/https-redirect-php.config . https://raw.githubusercontent.com/awsdocs/elastic-beanstalk-samples/master/configuration-files/aws-provided/security-configuration/https-redirect/php/https-redirect-php.config

3)I created the zip of the folder and deployed it on the server. 3)我创建了文件夹的zip并将其部署在服务器上。

4)I also tried using the eb cli command eb deploy but it is not working. 4)我也尝试过使用 eb cli 命令 eb deploy 但它不起作用。

Please suggest me any help.请建议我任何帮助。 I would be really thankful我会很感激

A solution consists to add to your .ebextensions directory a config file with the following lines : 解决方案是在.ebextensions目录中添加一个包含以下行的配置文件:

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

Take a look at Configuring Your Elastic Beanstalk Environment's Load Balancer to Terminate HTTPS 查看配置Elastic Beanstalk环境的负载均衡器以终止HTTPS

Go to ELASTIC BEANSTALK -> CONFIGURATION -> LOAD BALANCER -> RULES转到弹性 Beanstalk -> 配置 -> 负载平衡器 -> 规则

After you have your ports and your Certificate try to add this rules:拥有端口和证书后,尝试添加以下规则:

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM