httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Pitts" <>
Subject [users@httpd] mod_rewrite proxy with dynamic ProxyPassReverse
Date Thu, 26 Aug 2004 01:24:11 GMT
Hey all,

I have been searching for a solution to my problem and I found a lot of
sites that came close, but I have not been able to nail this one down.

I have been writing a Perl module to manage Apache2 processes, each of
which obviously runs on a different port. There is a main Apache process
that listens on port 80, which proxies requests to the appropriate server
on another port using a mod_rewrite RewriteMap. The following code shows
the mod_rewrite configuration for the server running on port 80:

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteLog logs/mod_rewrite-log
    RewriteMap aivh    prg:/usr/bin/aivh_rewriter
    RewriteRule ^proxy:.*  -  [F]
    RewriteRule ^(.*)$  http://${aivh:%{HTTP_HOST}}$1 [P]

The program /usr/bin/aivh_rewriter accepts the HTTP_HOST, does a lookup,
and returns a fully qualified domain name with a port number appended. For
instance, if the script were passed an HTTP_HOST of '',
it might return ''.

This provides the proper proxing of the client request, but it doesn't
provide the functionality of ProxyPassReverse when the backend server
sends a redirect. Unfortunately, there are too many hosts right now to
justify individual declarations of ProxyPassReverse. I thought about using
a <Perl> section to dynamically configure ProxyPass and ProxyPassReverse
based on the RewriteMap program, but that would require a server restart
every time a new host was added. Essentially, if mod_rewrite had another
flag, say 'PR', that implemented the functionality of ProxyPassReverse, I
would be golden. Is there a way to provide the same functionality as
ProxyPassReverse, but in a dynamic, per-request lookup fashion as with the
mod_rewrite RewriteMap?

I thank you in advance for your help.

Matt Pitts

The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message