----------------------------------------
> From: torsten.foert...@gmx.net
> To: modperl@perl.apache.org
> Subject: Re: mod_perl - separate PERL interpreter for each LocationMatch
> Date: Mon, 12 Sep 2011 11:52:57 +0200
> CC: uttamho...@live.com
>
> On Monday, 12 September 2011 11:04:35 utham hoode wrote:
> > I have written a mod_perl proxy server which redirects the HTTP
> > traffic to a webserver.
> > In the apache worker thread is enable. In the httpd.conf two
> > are configured
> > http://ipaddress/path1/
> > http://ipaddress/path2/
> > After starting the http server if i open any URL from the browser same
> > TEST_VAR is being printed
> > for both the URLs.
> > If I call path1 first then for both the URLs 100 is printed.
> > If I call path2 first then for both the URLs 200 is printed.
>
> I am still a bit at a loss what you are trying to do here. The phrase
> "modperl proxy server that redirects" is quite ambiguous:

Thanks for the quick response.
Sorry for not providing all the details. Actual proxy program is working fine 
withsingle <LocationMatch>. I wrote Test.pm just to demonstrate the issue.

>
> - a modperl handler that works in the response phase, mangles the request
> a bit before sending it to a backend server. On the way back the response
> from the backend is again a bit mangled perhaps and sent to the client
>
> - on the other hand it may be a server that sends out HTTP redirects to
> point the browser to the correct server using HTTP 3xx codes.
>
> - and thirdly it may be a piece of code working in a phase between
> maptostorage and fixup that modifies the request configuration to have it
> handled by mod_proxy.
>
> - perhaps there are a few more possible meanings
>
> Generally, apache creates an individual configuration for each request.
> At first it looks up the virtual server config. Then it merges into that
> one all the <Location> <Directory> <Files> blocks that are applicable.
>
> So, you can set a certain environment variable for one request to value1
> and for another to value2. But you have to have a distinguishing mark.
>
> > #startup.pl
> > use lib qw(/home/test1/libs);
> > 1;
> >
> > #---------------------------------
> >
> > # httpd.conf
> > PerlRequire /home/test1/startup.pl
> > #http://ipaddress/path1/
> >
> > SetEnvIf Request_URI "/" TEST_VAR=100
> > SetHandler perl-script
> > PerlResponseHandler Module::Test
> >
> > #http://ipaddress/path2/
> >
> > SetEnvIf Request_URI "/" TEST_VAR=200
> > SetHandler perl-script
> > PerlResponseHandler Module::Test
>
> In the snippet above I do not see any such mark. You set TEST_VAR to 100
> and to 200 if the request URI is /. That does not make sense.

I tried this but did not work.
SetEnvIf Request_URI "/path1/" TEST_VAR=100
and 
SetEnvIf Request_URI "/path2/" TEST_VAR=200


>
> >
> > #Test.pm
> > #--------------------------------------------------------------------
> > package Module::Test;
> > use strict;
> > use Apache2::Const qw(:methods :http :common);
> > use Apache2::Log ();
> > use Apache2::URI ();
> >
> > my $param = env_variable();
>
> Here you use a global variable that is set only once for the lifetime of
> the interpreter when the module is compiled. $param is not set for each
> request.


Here is the problem. Both path1 and path2 are sharing same global variable 
$param.Is there any way to avoid that?. Because In the actual proxy program I 
am reading aconfiguration file and storing it in a global variable. For path1 
and path2 configuration file is different. I can place the variable inside sub 
handler {}so that for  each request program loads the configuration file.I 
think this will reduce the performance.

>
> > sub handler
> > {
> > Apache2::ServerRec::warn($param);
> > print "Value".$param;
> > return Apache2::Const::OK;
> > }
> >
> > sub env_variable
> > {
> > # Configuration loading from a file during startup
> > my $endpointURL = $ENV{'TEST_VAR'};
> > return $endpointURL;
> > }
> > 1;
> > #---------------------------------------------------------------------
> > -----------
> >
> > But I tried with option and it is working fine as PerlOptions
> > +Parent is present.
> > But since the port numbers are different firefox will now allow
> > simulataneous access to
> > both URL from same webpage.
> >
> > #http://ipaddress:8080/path1/
> >
> > SetEnvIf Request_URI "/" TEST_VAR=100
> > PerlRequire /home/test1/startup.pl
> > PerlOptions +Parent
> >
> > SetHandler perl-script
> > PerlResponseHandler Module::Test
> >
> >
> >
> > #http://ipaddress:8085/path2/
> >
> > SetEnvIf Request_URI "/" TEST_VAR=200
> > PerlRequire /home/test1/startup.pl
> > PerlOptions +Parent
> >
> > SetHandler perl-script
> > PerlResponseHandler Module::Test
>
> +Parent is a VHost level option like:
>
> <VirtualHost ...>
> PerlOptions +Parent
> ...
> </VirtualHost>
>
> The virtual host then gets it's own perl interpreter. It has been
> requested a few times to make it possible to change the interpreter per
> request configuration but nobody has got around to do the work yet.
> Something along these lines would be good:
    I wish below feature is supported.

>
> <PerlInterpreter MyInterpreter>
> PerlSwitches ...
> PerlRequire ...
> PerlModule ...
> </PerlInterpreter>
>
> <PerlInterpreter OtherInterpreter>
> PerlSwitches ...
> PerlRequire ...
> PerlModule ...
> </PerlInterpreter>
>
> <Location /...>
> PerlUseInterpreter MyInterpreter
> </Location>
>
> Torsten Förtsch
>
> --
> Need professional modperl support? Hire me! (http://foertsch.name)
>
> Like fantasy? http://kabatinte.net
                                          

Reply via email to