4

If I have an ECS cluster with N distinct websites running as N services on said cluster - how do I go about setting up the load balancers?

The way I've done it currently is for each website X,

  • I create a new target group spanning all instances in the cluster
  • I create a new application load balancer
  • I attach the ALB to the service using the target group

It seems to work... but am want to make sure this is the correct way to do this

Thanks!

maambmb
  • 881
  • 1
  • 8
  • 18

1 Answers1

8

The way you are doing it is of course one way to do it and how most people accomplish this.

Application load balancers also support two other types of routing. Host based and path based.

http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#host-conditions

Host based routing will allow you to route based off of the incoming host from that website. So for instance if you have website1.com and website2.com you could send them both through the same ALB and route accordingly.

http://docs.aws.amazon.com/elasticloadbalancing/latest/application/load-balancer-listeners.html#path-conditions

Similarly you can do the same thing with the path. If you websites were website1.com/site1/index.html and website1.com/site2/index.html you could put both of those on the same ALB and route accordingly.

davis190
  • 306
  • 1
  • 4
  • can we target a particular service in ALB rules? basically, my requirement is to redirect to the relevant website using the domain name. without creating new ALB or new clusters. – ashen madusanka May 04 '22 at 18:17
  • As far as I can tell this is not possible. Typical options are the ones already specified in the answer above. – Cozzbie May 08 '22 at 19:37