Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

... I want to transparently give them the results of

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 until the final cutover.

Is mod_proxy the right way to go? I can't find any examples that appear to:

  1. Allow selective proxying (e.g. /foo/bar is proxied but /baz/ham is not),
  2. Pass along the entire path and querystring, and
  3. Keep the POST body and all HTTP headers in tact.

Any help would be greatly appreciated.

share|improve this question
up vote 3 down vote accepted

From what you describe a simple:

 ProxyPass /foo/

should work. All headers and GET/POST queries should just be forwarded fine. You may need a matching ProxyPassReverse depending on your setup and needs. If you need more control on which URLs are proxied you can use:

 ProxyPassMatch [regex] [url]

The official documentation does a pretty good job at explaining things. If you've tried to proxy like this and it doesn't work a new question with more specific details on what you've tried and what the exact issue is may get you better results.

share|improve this answer
Thanks! I can't do this in a .htaccess is the only problem, but I found that a RewriteRule with the [P] flag works as well. – Mike Griffith Dec 19 '12 at 20:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.