I'm using AWS Cloudfront as a "reverse proxy", with an Origin Server that has a non-empty "Origin Path", so paths on the origin server are different to paths seen by the client.
So my client might request /foo from Cloudfront, and it then requests /x/foo from my origin server and relays the response.
If the origin server returns a redirect, say to /x/foo2, then Cloudfront will return that redirect unmodified to the client. That doesn't work, because when the client follows that redirect, it incorrectly includes the /x origin path. For this to work, I need the client to see a redirect to /foo2 and not to /x/foo2.
How can I get Cloudfront to rewrite this redirect to remove the origin path from redirect responses when relaying them?
In Apache httpd, when it is acting as a reverse proxy, there is a feature called ProxyPassReverse to achieve this, see What is the use of ProxyPassReverse Directive . I can't find an equivalent feature for Cloudfront.
Relevant Cloudfront docs: