We have a fairly typical setup: client <-> apache2 (2.2.22) <-> backend (*).
Initially we were using mod_rewrite with the [P] flag in the simplest form:
<VirtualHost *:80>
RewriteEngine On
ProxyPreserveHost On
RewriteRule ^(.*)$ http://localhost:8081$1 [P,L]
</VirtualHost>
However using this setup, even when the clients used keep-alive connections and were sending multiple http requests using one tcp connection to apache, apache was creating a new tcp connection to the backend for reach request.
I decided to try using mod_proxy directly instead:
ProxyPreserveHost On
ProxyPass / http://localhost:8081/
And to my surprise now the tcp connections between apache and the backend are re-used (which was my initial goal).
Why is that? Is there something in mod_rewrite to configure to enable keepalive backend connections?
(*) The backend is actually haproxy <-> multiple app servers, but I don't think it matters here.