How do you route multiple microservices behind one domain with an ALB?
IntermediateScenarioLoad Balancing, Proxies & CDN
Answer
Situation read → Path and host based listener rules.
What I'd do →
- Create one ALB listener on 443 with a default fixed-response or main target group
- Add rules:
/api/*to the api target group,/auth/*to the auth target group,Host: admin.example.comto the admin group - Use
aws elbv2 create-rule --listener-arn <arn> --priority 10 --conditions Field=path-pattern,Values='/api/*' --actions Type=forward,TargetGroupArn=<tg> - Set health checks per target group
- Use IP target type for Kubernetes pods
Why → One public entry point reduces certificates, DNS records and cost.
Interview tip → Mention the 100 rules per listener default quota when the service count grows.
More on Load Balancing, Proxies & CDN
What is the difference between a Layer 4 and a Layer 7 load balancer?BeginnerWhen do you choose an ALB and when an NLB in AWS?BeginnerForward proxy versus reverse proxy: what is the difference?BeginnerHow do health checks work on a load balancer and what makes a good one?BeginnerWhat are sticky sessions and why would you avoid them?BeginnerWhat does a CDN do and when does it help?Beginner