You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Sumit Shah <ss...@gce2000.com> on 2006/12/07 21:37:08 UTC
MODPERL and Reverse Proxy
Hello All,
I am trying to setup my Apache in such a way that for any .jsp requests
it invokes a Perl Handler. After invoking the Perl handler, it should
use the Reverse proxy setup to forward the same request to another server.
Here is my configuration(httpd.conf):
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule perl_module modules/mod_perl.so
<FilesMatch "\.(jsp|cgi|gif|html)$">
PerlHeaderParserHandler My::RequestHandler
</FilesMatch>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://38.118.10.188:8035/
ProxyPassReverse / http://38.118.10.188:8035/
I want the request to come to My::RequestHandler FIRST and then go to
the ProxyPass Directive. It does not do this. It BYPASSES my handler and
goes to the Reverse Proxy.
I would appreciate any suggestions.
Thanks
Sumit
Re: MODPERL and Reverse Proxy [patch]
Posted by Radoslaw Zielinski <ra...@pld-linux.org>.
Jonathan Vanasco <mo...@2xlp.com> [08-12-2006 21:50]:
> On Dec 7, 2006, at 3:37 PM, Sumit Shah wrote:
>> I want the request to come to My::RequestHandler FIRST and then go
>> to the ProxyPass Directive. It does not do this. It BYPASSES my
I've been working on something like this recently...
[...]
> So you've got the chance to call a mp hook on
> PerlPostReadRequestHandler or PerlTransHandler
IIRC (can't check at the moment of writing this) I got it working with
PerlPostReadRequestHandler.
> Unfortunately, for that to happen under the current design of Apache/
> ModPerl/and ModProxy, you probably won't have the data you want
> available ( i believe you only have access to the URI at that phase )
IIRC URI and headers; I haven't tested if POST data is available.
> In order to get what you want done, you'll have to handle the Proxy
> internally -- ie, write a perl handler that will fetch the page using
> LWP or something, and then pass that content on.
This would be slow and is not necessary; just implement the ProxyPass
logic in mod_perl and set:
$r->proxyreq(Apache2::Const::PROXYREQ_REVERSE);
(Note: this constant has value of 2 and isn't mentioned in proxyreq()'s
documentation. Patch attached. There might also be something not quite
right with the $r->unparsed_uri description.)
--
Radosław Zieliński <ra...@pld-linux.org>
Re: MODPERL and Reverse Proxy
Posted by Jonathan Vanasco <jv...@2xlp.com>.
On Dec 8, 2006, at 3:59 PM, Frank Wiles wrote:
> Slightly off topic, but I was wondering could you just stack a I/O
> filter handler on the proxy? Anyone know if this is possible?
thats a good idea.
personally, i wish one could change when mod_proxy is called.
someone pointed to apache::proxy in the other thread. that looked neat.
at some point, mod_proxy needs to return content to an apache hook.
i don't know which one though. i guess one could profile apache to
figure out where you get it back -- then run something right after.
// Jonathan Vanasco
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
Re: MODPERL and Reverse Proxy
Posted by Frank Wiles <fr...@wiles.org>.
On Fri, 8 Dec 2006 15:50:56 -0500
Jonathan Vanasco <mo...@2xlp.com> wrote:
> On Dec 7, 2006, at 3:37 PM, Sumit Shah wrote:
>
> > I want the request to come to My::RequestHandler FIRST and then go
> > to the ProxyPass Directive. It does not do this. It BYPASSES my
> > handler and goes to the Reverse Proxy.
> > I would appreciate any suggestions.
Slightly off topic, but I was wondering could you just stack a I/O
filter handler on the proxy? Anyone know if this is possible?
I was thinking this type of technique might be useful when you
just want to clean up a legacy app's nasty HTML 3 into something
more modern. :)
---------------------------------
Frank Wiles <fr...@wiles.org>
http://www.wiles.org
---------------------------------
Re: MODPERL and Reverse Proxy
Posted by Jonathan Vanasco <mo...@2xlp.com>.
On Dec 7, 2006, at 3:37 PM, Sumit Shah wrote:
> I want the request to come to My::RequestHandler FIRST and then go
> to the ProxyPass Directive. It does not do this. It BYPASSES my
> handler and goes to the Reverse Proxy.
> I would appreciate any suggestions.
The Apache configuration doesn't process commands in the order that
they appear. It processes in the order that the request is
processed , as per the appropriate hook.
Look at this Apache Core API doc:
http://httpd.apache.org/docs/2.0/developer/request.html
Basically, during the request parsing phase, you have this:
Hook: translate_name
Hook: map_to_storage -- mod_proxy is always called here
Hook: header_parser -- you're calling mod_perl here
Now look at the MP docs
http://perl.apache.org/docs/2.0/user/handlers/http.html
"""
From the diagram it can be seen that an HTTP request is processed by
12 phases, executed in the following order:
PerlPostReadRequestHandler (PerlInitHandler)
PerlTransHandler
PerlMapToStorageHandler
PerlHeaderParserHandler (PerlInitHandler)
PerlAccessHandler
PerlAuthenHandler
PerlAuthzHandler
PerlTypeHandler
PerlFixupHandler
PerlResponseHandler
PerlLogHandler
PerlCleanupHandler
"""
So you've got the chance to call a mp hook on
PerlPostReadRequestHandler or PerlTransHandler
Unfortunately, for that to happen under the current design of Apache/
ModPerl/and ModProxy, you probably won't have the data you want
available ( i believe you only have access to the URI at that phase )
In order to get what you want done, you'll have to handle the Proxy
internally -- ie, write a perl handler that will fetch the page using
LWP or something, and then pass that content on.
See the current thread "using subrequest to different server"
// Jonathan Vanasco
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| FindMeOn.com - The cure for Multiple Web Personality Disorder
| Web Identity Management and 3D Social Networking
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -
| RoadSound.com - Tools For Bands, Stuff For Fans
| Collaborative Online Management And Syndication Tools
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - - -