Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

When using apache to reverse proxy, is it possible to forward and to different servers? Say one goes to http://internalserver1/ and the other goes to http://internalserver2/foo

I can obviously just drop further down the path (ie http://somesite/bar) but its not desirable.

share|improve this question
Take a look at Nginx as a reverse proxy over Apache, it's relatively new but has already surpassed LightHttp in use and it very fast and lightweight. – Swish Aug 6 '09 at 18:02
up vote 3 down vote accepted

it seems that order of directives in your vhost is important. and yes - you can achieve what you need. i just run test for:

ProxyPass /q
ProxyPass /

and it worked fine - all requests [ except those directed to /q/something ] ware proxied to those for /q/whatever - went to

share|improve this answer
hmm, this didnt work for me, i ended up with the same issue without order - all links went to (in your example) did you include ProxyPassReverse? – Devnull Jul 22 '09 at 21:05
@ANervousTwitch i'm sorry to hear it but this actually does work for me. no - i do not have ProxyPassReverse, only two lines for proxy: "ProxyPass /q"; and "ProxyPass /"; after that. – pQd Jul 22 '09 at 21:19
@ANervousTwitch - i'm using apache 2.2.9-10 from debian. – pQd Jul 22 '09 at 21:19
I agree that this should work. – radius Jul 22 '09 at 22:58

You should be able to do this using mod_rewrite. It evaluates conditions in order and you can specify the [L] flag to make it stop processing further rules.

RewriteEngine On
RewriteRule /foo/(.*) http://internalserver2/foo/$1 [P,L]
RewriteRule /(.*)     http://internalserver/$1 [P]

Full mod_rewrite documentation is at

share|improve this answer

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.