You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Matthew Pitts <in...@nvinity.net> on 2004/08/26 03:24:11 UTC
[users@httpd] mod_rewrite proxy with dynamic ProxyPassReverse
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]
</IfModule>
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 'www.somedomain.com',
it might return 'www.somedomain.com:9000'.
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
invinity@nvinity.net
---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscribe@httpd.apache.org
" from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org