For local test, I'm using Charles proxy, for those who don't know about it is a tool to debug HTTP requests. It can be configured to act as a proxy and intercept requests/responses and is able to do several things with it, like the most important for me, "remap" a domain to another.

It means that when I want set up the proxy on my mobile device and try to access a.domain.tld and b.domain.tld I can configure Charles to redirect transparently data to c.domain.tld and d.domain.tld.

This is what I want to do with Apache (preferably) (but suggestion are welcome).

I know a little about mod_proxy but I couldn't find any similar example, I bet I can do something with it while playing around with the rewrite mod, but I'm sure there is a simple thing to do.

What I want to do:

  • Configure a vhost within apache called proxy.domain.tld
  • It will act as any proxy except for the domain a.domain.tld and b.domain.tld for which it will target c.domain.tld and d.domain.tld respectively instead.

Any advices?

  • In other words: you want to set up a proxy that will transparently hijact certain requests and divert them to some other hosts? – Laas May 16 '13 at 7:47
  • @Laas, exactly, I want to test some live mobile application against a new code base – Boris Guéry May 16 '13 at 7:53

Shooting from the hip, the ProxyRemote should be the thing you are looking for. The intent of that directive is to allow one proxy to forward some requests to next while serving others directly. Untested, but it should be possible to use this to your advantage:

ProxyRequests On
ProxyVia On

<Proxy *>
  Order deny,allow
  Deny from all
  Allow from

  # Redirect these two domains to different destination
  ProxyRemote http://a.domain.tld http://c.domain.tld
  ProxyRemote http://d.domain.tld http://d.domain.tld

NB!: Be sure to fill in some real IP numbers or other authentication, so you dont create yourself an open proxy.

  • thank you for your answer, I give it a try but I couldn't make the ProxyRemote directive work – Boris Guéry May 17 '13 at 9:17
  • Maybe set LogLevel debug and scan the logs to see what happens. I'm not exactly sure whether the ProxyRemote endpoints can be regular HTTP servers or must they be proxies themselves too. – Laas May 17 '13 at 12:21

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.