Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create AWS Application Load Balancer Rule which trim off request's prefix without using additional reverse proxy like nginx, httpd

Basically, I have a couple of services. I want to forward every requests with prefix "/secured" to server1 port 80 and all other requests to server 2 port 80. The problem is that on server1, I am running service which accept the request without "/secured" prefix. In other words, I want to forward every requests such as "http://example.com/secured/api/getUser" to server1 as "http://example.com/api/getUser" (remove /secured from request' path).

With AWS ALB, currently the request is sent as http://example.com/secured/api/getUser; which forces me to update my server1's code so that the code handles requests with /secured prefix which doesn't look good.

Is there any easy way to solve this with ALB?

Thanks.

like image 250
auxdx Avatar asked Sep 04 '16 13:09

auxdx


1 Answers

I can confirm that this is unfortunately not possible with the ALB alone - and I agree it really should be.

AWS states:

Note that the path pattern is used to route requests but does not alter them. For example, if a rule has a path pattern of /img/*, the rule would forward a request for /img/picture.jpg to the specified target group as a request for /img/picture.jpg.

like image 77
Kong Avatar answered Sep 21 '22 10:09

Kong