Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Apache httpd used as a SSL reverse proxy frontend for a lot of backends. I compute the name of the backend from the path given by the user. e.g: translates to

For this I use a RewriteMap and RewriteRule with [P] flag on. Everything works fine.

However I now need a persistent connection between the reverse proxy and the backend. I am well aware that keep-alive doesn't work with RewriteRule's [P] ( - performance warning) therefore I tried to use ProxyPass and environment variable interpolation to do the work. I got a RewriteRule that don't do nothing except saving the map result into an environment variable and then call the ProxyPass using this variable.

RewriteMap mymap prg:/path/to/my/map
RewriteCond %{REQUEST_URI} ^/([^/]+)/?.*$
RewriteCond ${mymap:%1} ^http://([^/]+/)$
RewriteRule ^/([^/]+)/?$ - [L,E=original:$1,E=rewritten:%1]

ProxyPassInterpolateEnv On
ProxyPassReverse /${original}/ http://${rewritten} interpolate

This result in the same behaviour as RewriteRule with [P]: the proxying is ok but don't uses http keep-alive.

I tried this with a hard-coded hostname instead of using ${rewritten} (but keeping the ${original}) and observed that it's the part that make Apache creating new connection instead of reusing an existing one.

This bug: is raising the same issue and propose a patch that may solve my problem.

However, I wanted to know if anyone had an idea to solve this in a different/better way.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.