Introduction Path-based routing misconfiguration causes requests to be sent to the wrong backend service. This breaks microservice architectures where different URL paths map to different services.
Symptoms - /api/* requests going to frontend server instead of API server - 404 errors for paths that should be routed - Static assets not served correctly - Path rewrite not working as expected - Default backend receiving traffic meant for specific paths
Common Causes - Path rule priority incorrect (catch-all before specific rules) - Path pattern syntax error (glob vs regex) - Backend service not available for the path - Path rewrite rule stripping required prefix - Trailing slash mismatch in path patterns
Step-by-Step Fix 1. **Check current routing rules': ```bash # AWS ALB aws elbv2 describe-rules --listener-arn <arn> \ --query "Rules[*].{Priority:Priority,Conditions:Conditions,Actions:Actions}" ```
- 1.**Fix rule priority':
- 2.```bash
- 3.# Higher priority rules (lower number) evaluated first
- 4.aws elbv2 set-rule-priorities --rule-arns <specific-rule-arn> --priorities 1
- 5.aws elbv2 set-rule-priorities --rule-arns <catch-all-rule-arn> --priorities 999
- 6.
` - 7.**Test path routing':
- 8.```bash
- 9.curl -s -o /dev/null -w "%{http_code}" https://lb.example.com/api/health
- 10.curl -s -o /dev/null -w "%{http_code}" https://lb.example.com/static/logo.png
- 11.
`