How to configure apache's mod_proxy_html to work as an ajax proxy?

Here's a thought on how to do this - it's a bit more complex in setup, but I think it would be secure. I'm currently unable to test this since I can't get at my test server, but it's a start.

The main problem is that if you just set up a ProxyPassReverse, you also need to specify which servers you connect to. Since you want to be able to use this on multiple servers, that would be a bit of a pain, to put it mildly. So here's a two-step approach to neatly sidestep this problem.

First, setup a separate apache instance to listen only on 127.0.0.1 and a specific port - I've gone with 2323 in my example. This instance should be configured as a straightforward proxy server and do no rewriting. Example:

<Proxy *>
   Order Deny,Allow
   Deny from all
   Allow from 127.0.0.1
</Proxy> 

On your main server, set up a reverse proxy, something like this:

<Location /proxy/>
    ProxyPass http://127.0.0.1:2323
    ProxyPreserveHost On
    ProxyHtmlEnable ON
    ProxyHtmlMap / /proxy/
</Location> 

This will mean that the actual proxying works as a regular proxy, while the rewriting happens in the same apache instance where the script runs. Again, note that this is untested, but I think it's the right direction to start looking.