Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 1 down vote accepted

mod_proxy does connection pooling. mod_rewrite doesn't.

share|improve this answer
    
Is there a way to configure mod_rewrite to do connection pooling as well? Is it documented anywhere in the docs (I couldn't find anything)? –  adamw Sep 3 '12 at 15:07
    
Again, mod_rewrite does not do connection pooling. –  Ansgar Wiechers Sep 3 '12 at 17:31
    
Ok, got it, just wanted to make sure it's not configurable. It should be mentioned in the docs, though :) –  adamw Sep 3 '12 at 19:56
    
See also my blog with a more detailed explanation of the problem: warski.org/blog/2012/09/… –  adamw Sep 19 '12 at 17:11

Using a pair of dummy ProxyPass directives as described in http://www.gossamer-threads.com/lists/apache/users/336740 allows the use of connection pooling with a RewriteRule.

share|improve this answer
    
Thanks for the answer Havenless. At ServerFault, we prefer if you quote the most important parts of your links here instead of only posting a link –  MichelZ May 9 at 11:07

Your Answer

 
discard

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.