简体   繁体   中英

Host Headers implementation with shared ALB and Elastic Beanstalk

I'm trying to modify the default Host Header CNAME attach to the rule when using a shared ALB with ElasticBeanstalk configuration. By using Terraform, here's how my configuration look like:

    {
      namespace = "aws:elasticbeanstalk:environment"
      name      = "LoadBalancerIsShared"
      value     = "true"
    },
    {
      namespace = "aws:elbv2:listener:443"
      name      = "Rules"
      value     = "default"
    },
    {
      namespace = "aws:elbv2:loadbalancer"
      name      = "SharedLoadBalancer"
      value     = data.aws_lb.default.arn
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "DeregistrationDelay"
      value     = "20"
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "HealthCheckInterval"
      value     = "15"
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "HealthCheckTimeout"
      value     = "5"
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "HealthyThresholdCount"
      value     = "3"
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "Port"
      value     = "80"
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "Protocol"
      value     = "HTTP"
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "StickinessEnabled"
      value     = "false"
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "StickinessLBCookieDuration"
      value     = "86400"
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "StickinessType"
      value     = "lb_cookie"
    },
    {
      namespace = "aws:elasticbeanstalk:environment:process:default"
      name      = "UnhealthyThresholdCount"
      value     = "5"
    },
    {
      namespace = "aws:elbv2:listenerrule:myrule"
      name      = "HostHeaders"
      value     = "my.example.com"
    },
    {
      namespace = "aws:elbv2:listenerrule:myrule"
      name      = "Process"
      value     = "default"
    }

Based on this AWS documentation , it should just work, but somehow, the Host Header attached to the Shared ALB always end up using region.elasticbeanstalk.com as follow:

EB 负载均衡器配置 共享 ALB 规则

Thanks again for your help!

What you're seeing in your load balancer is the default rule, and that's because you didn't include your custom rule in the ELB's setting.

Try this:

...
    {
      namespace = "aws:elbv2:listener:443"
      name      = "Rules"
      value     = "default,myrule"
    },
...

Let me know if that helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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