I'm using an ELB (Elastic Load Balancer) on Amazon Webservices (spezifically an Application Load Balancer).
The Problem: I want to create a rule to rewrite the path, but need to insert a string within the path.
When a request is coming in to:
example.org/api/foo/*
I need it to be redirected to:
example.org/api/v1/foo/*
The rest of the request needs to stay the same. The problem is that the original value of path cannot be altered. One way of cause would be to add every possible path as a rule. But when expanding the api it would be extremly uncomfortable.
Rewriting is not supported by the ELB as you already discovered.
Some options:
1) Implement a webserver e.g. nginx between the ALB and your application, which can implement rewrite rules
2) Path-based rewriting can be achieved by using Route53 -> CloudFront -> Lambda -> ALB
, instead of straight up Route53 -> ALB
, as demonstrated here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With