Search code examples
amazon-web-servicesamazon-ec2aws-application-load-balancer

aws Path-based load balancer not changing paths


I have a system where I use a load balancer to do path-based redirects where depending on the path, it will redirect to a different domain or EC2 app. 8 The way I have it set up now, all HTTP requests get forwarded to HTTPS, and that works fine.

For all HTTPS requests, I want it so that a path to www.abc.com/* always gets redirected to www.abc.app/* EXCEPT for one path, which is www.abc.com/game

I have two listeners setup:

  1. www.abc.com/game gets routed to a target group that is linked to an EC2 instance hosting a nodejs app. I can access this through port 3000 fine using the native EC2 IP. This is the highest priority listener
  2. The last priority listener takes the HTTPS://#{host}:443/#{path}?# pattern and redirects it to www.abc.app/*

The issue is, listener #1 seems to be completely ignored because the www.abc.com/game path gets redirected to www.abc.app/game instead of routing it to the EC2 server.

I checked my conditional logic and I have it as the following: If abc.com/game OR www.abc.com/game OR variations containing the "https" prefix then redirect to EC2 target group

Is there any clue as to why this listener is not triggering?


Solution

  • You should set the rule to have a host header condition and then a path condition as in the screenshot below:

    enter image description here

    This is the high priority rule. You can also forward if there is any suffix to /game by using below rule:

    enter image description here