我在Elastic Beanstalk环境中使用ALB。它工作(80和443)但我想在cloudformation模板中实现重定向规则。
我能够在控制台中创建规则:
If PATH is / Redirect to HTTPS://#{host}:443/app?#{query}
如何在CloudFormation中的Elastic Beanstalk中为ALB执行此操作?
您可以添加作为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