You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Brian Hirt <bh...@mobygames.com> on 2002/10/17 20:03:37 UTC

question about using a proxy with mod_perl

I have a question about setting up a proxy for a mod_perl server.  I've
got a simple proxy set up that listens on port 80 and proxies to the
mod_perl server running on a different port.  

For example. http://blah.blah.com/anything/ will go to
http://blah.blah.com:4374/anything/  and the rules to do that are below.

RewriteEngine     on
RewriteLogLevel   0
RewriteRule       ^/(.*)$  http://blah.blah.com:4374/$1   [P,L]
NoCache           *
ProxyPassReverse  /  http://blah.blah.com/

This is fine when you are proxying a single machine name, but how would
i set up a proxy that would send http://a.blah.com ->
http://a.blah.com:4374,  http://b.blah.com -> http://b.blah.com:4374,
etc etc etc.  There are about 40 different names that need to be
proxied, and it's important that the destination name is the same as the
source machine name.

It seems like something like 
RewriteRule	^http://([^.]+).blah.com/(.*)$   http://$1.blah.com:4374/$2
[P,L] 

should work, but it doesn't.

-- 
Brian Hirt <bh...@mobygames.com>


Re: question about using a proxy with mod_perl

Posted by Lyle Brooks <br...@deseret.com>.
I believe that the Rewrite rule matches only the document root portion
of the URL.

So for a request

   http://a.blah.com/mypath/mypage.html

All you will get to match on is this much

                    /mypath/mypage.html

To do what you are trying to do, I believe you'll need to use some RewriteCond
directives, something like (read: I'm just doing this from memory, you'll
need to test)...

RewriteCond %{HTTP_HOST} ^b
RewriteRule ^/(.*)         http://b.blah.com:4374/$1  [P,L]


Hope that helps or points you in the right direction.

Quoting Brian Hirt (bhirt@mobygames.com):
> 
> I have a question about setting up a proxy for a mod_perl server.  I've
> got a simple proxy set up that listens on port 80 and proxies to the
> mod_perl server running on a different port.  
> 
> For example. http://blah.blah.com/anything/ will go to
> http://blah.blah.com:4374/anything/  and the rules to do that are below.
> 
> RewriteEngine     on
> RewriteLogLevel   0
> RewriteRule       ^/(.*)$  http://blah.blah.com:4374/$1   [P,L]
> NoCache           *
> ProxyPassReverse  /  http://blah.blah.com/
> 
> This is fine when you are proxying a single machine name, but how would
> i set up a proxy that would send http://a.blah.com ->
> http://a.blah.com:4374,  http://b.blah.com -> http://b.blah.com:4374,
> etc etc etc.  There are about 40 different names that need to be
> proxied, and it's important that the destination name is the same as the
> source machine name.
> 
> It seems like something like 
> RewriteRule	^http://([^.]+).blah.com/(.*)$   http://$1.blah.com:4374/$2
> [P,L] 
> 
> should work, but it doesn't.
> 
> -- 
> Brian Hirt <bh...@mobygames.com>