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. 1.**Fix rule priority':
  2. 2.```bash
  3. 3.# Higher priority rules (lower number) evaluated first
  4. 4.aws elbv2 set-rule-priorities --rule-arns <specific-rule-arn> --priorities 1
  5. 5.aws elbv2 set-rule-priorities --rule-arns <catch-all-rule-arn> --priorities 999
  6. 6.`
  7. 7.**Test path routing':
  8. 8.```bash
  9. 9.curl -s -o /dev/null -w "%{http_code}" https://lb.example.com/api/health
  10. 10.curl -s -o /dev/null -w "%{http_code}" https://lb.example.com/static/logo.png
  11. 11.`

Prevention - Document path routing rules and their priorities - Test path routing after any rule changes - Use specific path rules before catch-all rules - Monitor 404 rate from load balancer - Implement path-based routing validation in CI/CD