Does AWS offer a way to route HTTPS traffic to two different EC2 instances based on directory path?

Use the AWS Application Load Balancer, which does Path Based Routing. That second link is a tutorial how to do it.

In short, you set up your ALB as normal, then follow these steps (copied from the AWS tutorial):

  • On the Listeners tab, use the arrow to view the rules for the listener, and then choose Add rule. Specify the rule as follows:

  • For Target group name, choose the second target group that you created.

  • For Path pattern specify the exact pattern to be used for path-based routing (for example, /img/*). For more information, see Listener Rules.

  • Choose Save.

Leave a Comment