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.

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: https://myhostname.com/myaccount translates to http://myaccount.myhostname.com

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] (http://httpd.apache.org/docs/current/en/rewrite/flags.html#flag_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: https://issues.apache.org/bugzilla/show_bug.cgi?id=43308 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.