For example I want to set up a forward proxy to forward HTTP requests to a.com, b.com, c.com to a.mirror.com, b.mirror.com, c.mirror.com.

Currently I have to configure 3 vhosts as:

  ServerName a.com
  ProxyPass / http://a.mirror.com/
  ServerName b.com
  ProxyPass / http://b.mirror.com/
  ServerName c.com
  ProxyPass / http://c.mirror.com/

Is there any way to rewrite the domain part of http request? as:

ProxyPassMatch http://(.*).com/ http://$1.mirror.com/

I wonder if I must do it by RewriteRules, but I don't know how to write the rule exactly and the performance of RewriteRule v. ProxyPass, but performance isn't a big problem.

migrated from superuser.com Dec 19 '09 at 13:23

This question came from our site for computer enthusiasts and power users.


Depending on the details of your exact setup, this can be done using mod_rewrite. You would probably match on HTTP_HOST, strip out the part of the hostname that you want, and tack it onto .mirror.com, then use mod_rewrite's [P] flag to enable the proxy.

This isn't exactly what you want, but it might get you a little closer:



You want something like this:

RewriteCond %{HTTP_HOST} ^(.*)\.com
RewriteRule (.*) %{SERVER_PROTOCOL}://%1.mirror.com$1 [P]


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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