Hi All,

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.

#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


#Test.pm
#--------------------------------------------------------------------
package Module::Test;
use strict;
use Apache2::Const qw(:methods :http :common);
use Apache2::Log ();
use Apache2::URI ();

my $param = env_variable();
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



Regards,
uttam


----------------------------------------
> 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 10:18:59 +0200
> CC: uttamho...@live.com
>
> On Monday, 12 September 2011 09:22:57 utham hoode wrote:
> > Hi All, I have written a mod_perl proxy server which redirects
> > the HTTP traffic to a webserver. I have pasted the snippet below.
> > 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 printedfor 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.(that is its taking the first called Path, after httpd
> > is started) #----------------------------Startup.pl
> > --------------------------------------------##startup.pl use lib
> > qw(/home/test1/libs); 1; #---------------------------------
> > #----------------------------
> > httpd.conf---------------------------------------------# #
> > 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
> > #--------------------------------------------------------------------
> > -----------# #---------------------------- Test.pm
> > ---------------------------------------------# # Test.pm package
> > Module::Test; use strict; use Apache2::Const qw(:methods :http
> > :common);use Apache2::Log ();use Apache2::URI (); my $param =
> > env_variable(); 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 toboth URL from
> > same webpage. #http://ipaddress:8080/path1/
> > SetEnvIf Request_URI "/" TEST_VAR=100 PerlRequire
> > /home/test1/startup.pl PerlOptions +Parent > /path2/> 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
> > Please help me with this, Thanks in
> > advance.Regards,uttam
>
> Could you please resend the mail with proper line breaks? Otherwise, it's
> indecipherable, at least for me.
>
> Torsten Förtsch
>
> --
> Need professional modperl support? Hire me! (http://foertsch.name)
>
> Like fantasy? http://kabatinte.net                                      

Reply via email to