Step 1 — Prepare Two Target Groups
- Create (or reuse) group A for the website targets.
- Create group B for the API targets.
- Confirm both groups show healthy targets.

On an Application Load Balancer, path-based routing sends different URL paths to different target groups.
Example:
/api/* → API servers/* → website serversOne DNS name, one ALB, multiple backends. A Network Load Balancer cannot do this.
Microservices often share www.example.com but live on different instances. Path rules keep one certificate and one hostname while splitting traffic.
Path = after the domain (/api). Host = the domain name itself (api.example.com). Related redirects: www to non-www.
Listener rules for Application Load Balancers.
| Word | Plain meaning |
|---|---|
Listener | ALB port/protocol that receives client traffic (80/443) |
Rule | Conditions (path/host/…) + action (forward/redirect) |
Priority | Order rules are checked; lower number wins first |
Path pattern | Match like /api/* or /images/* |
Default action | Catch-all when no other rule matches |
Target group | Backends that receive the forwarded requests |
/api/*/api or /api/* (match your app).
/* rule with a higher priority number than /api/*.http://ALB-DNS/ — should hit the website group.http://ALB-DNS/api/... — should hit the API group.A high-priority /* steals API traffic. Put /api/* first.
Rules forward only to healthy targets—fix health checks.
Use ALB (Layer 7) for HTTP path matching.
/api and /api/* match differently—match what your clients request.
One line: two target groups, a specific /api/* rule, then a default forward for the rest.
Register instances and wire groups before adding more listener rules.
CODETOFUN NEWS
Get the latest IT news, programming updates, and technology trends directly on your phone.
Your daily dose of tech, straight to your feed.
9 people found this page helpful