amazon-web-servicesload-balancingelastic-load-balanceramazon-elb

Query string in AWS Application Load Balancer


I want to route everything going to service.php to be routed to a specific target group, even if it has a query string or not. Do I need to define it with a wildcard or is just defining /service.php sufficient enough?

/service.php vs /service.php*

In addition to this, I also want to route a specific query with its parameters to another target group, how would I define this? Could I just do /service.php?mobile=true*?


Solution

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

    the paths are regular expressions that need to exactly match so you would need to define a rule like /service.php*

    To handle sending mobile requests to a different target group you might create two rules with different priority. Elastic Load Balancing evaluates rules in priority order, from the lowest value to the highest value. If a request satisfies a rule, Elastic Load Balancing ignores all subsequent rules, so you would want your mobile rule to have a lower priority than your service rule.

    /service.php?mobile?true*

    /service.php*

    Note the allowed characters in the documentation.