Search code examples
amazon-web-servicesaws-api-gatewayaws-application-load-balancer

AWS API Gateway with VPC Load Balancer redirects to incorrect path (prefix not omitted)


I want to use API Gateway to route between multiple microservices. E.g: domain.com/app1, domain.com/app2 etc.

  • Each service has an internal Application Load Balancer (ALB).
  • API Gateway has a VPC Link configured correctly.

The problem is that routes such as domain.com/app1/hello are redirected to internal.app1/app1/hello instead of internal.app1/hello.

  • Notice that the prefix app1 is not removed.

It can be solved when I use HTTP redirection in API Gateway, but that requires an external load balancer which I want to avoid. I didn't see an option to use path variables with private ALB integration.

Please advise. Thank you in advance.


Solution

  • Problem is solved.

    The solution is to use a REST API Gateway (instead of HTTP Gateway) integrated with a Network Load Balancer (NLB) via a VPC Link.

    The AWS REST API in AWS API Gateway allows using path variables with private integration (in this case, the NLB).

    Summary of the solution:

    • API Gateway REST API
    • Private Network Load Balancer
    • REST API VPC Link (to the NLB)
    • Use a proxy resource with private integration in the routes configuration