【问题标题】:AWS EB config file, redirect http to httpsAWS EB 配置文件,将 http 重定向到 https
【发布时间】:2020-04-11 08:11:33
【问题描述】:

我正在尝试弄清楚如何写入配置文件以部署 Elastic Beanstalk 环境。

我想做一个从 http 到 https 的重定向。我可以在启动应用程序后通过控制台执行此操作,但我希望它自动发生。

类似

OptionSettings:
  aws:elbv2:listener:80:
    ListenerEnabled: true
    DefaultProcess: default
    Protocol: HTTP
    Rules: 'httpsonly'
  aws:elbv2:listenerrule:httpsonly:
    # stuff ???

我似乎找不到任何示例或正确的文档。

控制台规则如下所示:

【问题讨论】:

    标签: amazon-web-services amazon-elastic-beanstalk amazon-elb


    【解决方案1】:

    AWS 文档说通过服务器文件来实现。

    对于 PHP apache 放入 .ebextensions 文件

    files:
       /etc/httpd/conf.d/http-redirect.conf:
         mode: "000644"
         owner: root
         group: root
         content: |
           RewriteEngine On
           RewriteCond %{HTTP:X-Forwarded-Proto} !https
           RewriteCond %{HTTP_USER_AGENT} !ELB-HealthChecker
           RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
    

    见:https://docs.aws.amazon.com/en_us/elasticbeanstalk/latest/dg/configuring-https-httpredirect.html
    和:https://github.com/awsdocs/elastic-beanstalk-samples/blob/master/configuration-files/aws-provided/security-configuration/https-redirect/php/https-redirect-php.config

    【讨论】:

      猜你喜欢
      • 2016-09-26
      • 2019-02-13
      • 2012-05-07
      • 1970-01-01
      • 2018-02-18
      • 2019-12-14
      • 2019-06-25
      • 2014-02-06
      • 2018-03-14
      相关资源
      最近更新 更多