3

我在我的 Elastic Beanstalk 环境中使用 ALB。它可以工作(在 80 和 443 上),但我想在 cloudformation 模板中实现重定向规则。

我能够在控制台中创建规则:

If PATH is / Redirect to HTTPS://#{host}:443/app?#{query}

如何在 CloudFormation 中为 Elastic Beanstalk 中的 ALB 执行此操作?

4

1 回答 1

3

您可以添加作为 cloudformation 片段的 EB 扩展。它看起来像这样:

albRedirect:
  Type: AWS::ElasticLoadBalancingV2::Listener
  Properties:
    DefaultActions:
      - Type: redirect
        RedirectConfig:
          Protocol: HTTPS
          Host: '#{host}'
          Query: '#{query}'
          Path: '/#{path}'
          Port: '443'
          StatusCode: HTTP_301
    LoadBalancerArn: !Ref AWSEBV2LoadBalancer
    Port: 80
    Protocol: HTTP

https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-resources.html

于 2019-03-04T12:59:13.627 回答