Back to Articles
AWSApi GatewayMicroservices

How to Route Traffic to Multiple Microservices with AWS API Gateway

March 11, 2026
2 min read
How to Route Traffic to Multiple Microservices with AWS API Gateway

I recently set up AWS API Gateway to forward requests to two different microservices. Here’s how I did it step by step πŸ‘‡

The Goal

I had two backend services behind their own load balancers:

  • User Service: http://user-lb-1148255498.ap-south-1.elb.amazonaws.com
  • Order Service: http://order-lb-1634505146.ap-south-1.elb.amazonaws.com

I wanted:

  1. /api/users β†’ User service
  2. /api/orders β†’ Order service
  3. Any extra path after these (like /health) should also go to the correct service.

Step 1: Create an HTTP API

  1. Go to API Gateway β†’ HTTP API β†’ Create API.
  2. Choose Manual route configuration.
  3. Give it a name like MicroserviceGateway.
  4. Choose HTTP integration.
  5. Add both services one by one:

User Service Integration:

  • URL: http://user-lb-1148255498.ap-south-1.elb.amazonaws.com
  • Proxy URL: http://user-lb-1148255498.ap-south-1.elb.amazonaws.com/{proxy}

Step 2: Add Routes and Connect Integrations

For each service, create two routes β€” one for the base path and one for everything after it.

User Service

  • /api/users β†’ Integration: User LB
  • /api/users/{proxy+} β†’ Integration: User LB

Note: {proxy+} means it will forward any subpath after the main route to the backend. For example, /api/orders/health goes to /health on the Order service.


Step 3: Deploy the API

  1. Go to Deployments β†’ Create Deployment.
  2. Create a stage named prod.
  3. Click Deploy.

You’ll now get a single URL like this: https://abc123xyz.execute-api.ap-south-1.amazonaws.com/prod


πŸ” Step 4: Test the Setup

Try calling these endpoints to confirm they route correctly:

  • /prod/api/users β†’ goes to User service
  • /prod/api/users/health β†’ goes to User service /health
  • /prod/api/orders β†’ goes to Order service

πŸ’‘ Key Tips

  • Always add both: A base route and a proxy route.
  • Use {proxy+}: To catch all subpaths effectively.
  • Set method = ANY: To allow GET, POST, PUT, etc., to flow through.
  • Test Backends First: Confirm your LBs are reachable before connecting them.

βœ… That’s it! Now you have a single API Gateway URL that routes traffic cleanly to multiple microservices.

Keep Reading

Shubham

Shubham

Full Stack Developer