I'm moving a web application to a new set of servers in a different data center. As part of a beta period, I want to configure the old server as a reverse proxy for some requests, based on a pattern in the URL.
For example, if someone requests:
http://old.example.com/foo/bar?q=1
... I want to transparently give them the results of
http://new.example.com/foo/bar?q=1
Redirects won't work, as this is used as an API and some clients don't properly follow redirects (fixing the clients isn't an option). Also, this needs to work for both GET and POST requests.
The list of URLs to proxy would be selective, e.g. so that only the "foo/*"
requests would be proxied, and the others would just be served by old.example.com until the final cutover.
Is mod_proxy
the right way to go? I can't find any examples that appear to:
- Allow selective proxying (e.g.
/foo/bar
is proxied but/baz/ham
is not), - Pass along the entire path and querystring, and
- Keep the POST body and all HTTP headers in tact.
Any help would be greatly appreciated.