perl-modperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From SHAHNAWAZ OSMAN <compuerworl...@yahoo.ca>
Subject the scripts under mod_perl are running as mod_cgi
Date Wed, 01 Dec 2004 11:16:36 GMT
Hi! I have been trying to configure two servers under Linux (CentOS-3.3) - one vanilla (frontend)
& one mod_perl (backend) enabled server with a proxy setting in the front end. The frontend
server is on port: 80 and the backend is on port 8000 and they are both in the same IP. The
installation seems successful and the error log is as follows:
 
  [Wed Nov  24 02:53:55 2004] [notice] Apache/1.3.33 (Unix) mod_perl/1.29 configured -- resuming
normal operations
  [Wed Nov  24 02:53:55 2004] [notice] Accept mutex: sysvsem (Default: sysvsem)
 
I can also verify that mod_perl is installed by typing 'httpd -l'. Anyway, the configuration
became a real pain since all I can get is only "running under mod_cgi" - if I run the following
script:
 
-----------------------------------------------------------------------------------------
#!/usr/bin/perl 
print "Content-type: text/plain\n\n"; 
print "running under mod_" . ($ENV{MOD_PERL} ? "perl" : "cgi"); 
-----------------------------------------------------------------------------------------
 
I am really confused and can't figure out a solution so far. I tried to follow the guideline
and reading a lot in the last few days but I don't seem to find a clue. I would really appreciate,
if you guys can point out - what am I doing wrong here. Thank you in advance.
Here are my settings...

This is the frontend configuration setting...
 
++++++++++++++++++++++
++  httpd.conf - start            ++
++++++++++++++++++++++
 LoadModule proxy_add_forward_module  libexec/mod_proxy_add_forward.so
 LoadModule proxy_module       libexec/mod_proxy.so
 
 
 AddModule mod_proxy_add_forward.c
 AddModule mod_proxy.c
 
 
 <IfModule mod_proxy.c>
 ProxyRequests On
 ProxyPass /perl/ http://localhost:8000/cgi-bin/
 ProxyPassReverse /perl/ http://localhost:8000/cgi-bin/
 </ifModule>
 
 # I added the following line inside the '<VirtualHost xxx.xx.xx.xxx>' tag
 
 <VirtualHost xx.xx.xx.xxx:80>
 ........
 ........
 Alias /perl/ /home/user-name/public_html/cgi-bin/
 ........
 ........
 </<VirtualHost>
 
++++++++++++++++++++++
++  httpd.conf - end             ++
++++++++++++++++++++++
Here is the backend config file for mod_perl enabled server...
++++++++++++++++++++++
++ httpd_perl.conf - start ++
++++++++++++++++++++++
 BindAddress 127.0.0.1
 
 port 8000

 ##### mod_perl settings#####
 PerlRequire         /usr/local/httpd_perl/conf/startup.pl
 PerlFixupHandler      Apache::SizeLimit
 PerlPostReadRequestHandler Book::ProxyRemoteAddr
 PerlSetupEnv        Off
 
  
 Listen 8000
 <VirtualHost localhost:8000>
 ServerAlias www.mydomain.com mydomain.com
 ServerAdmin webmaster@mydomain.com
 ServerName www.mydomain.com
 DocumentRoot /home/user-name/public_html
 DirectoryIndex index.shtml index.html
 
 ScriptAlias /cgi-bin/ /home/user-name/public_html/cgi-bin/
 Alias /perl/ /home/user-name/public_html/cgi-bin/
 PerlModule Apache::Registry
 
 <Location /perl>
 SetHandler perl-script
 PerlHandler Apache::Registry
 PerlSendHeader On
 Options +ExecCGI
 Allow from all
 </Location>
 </VirtualHost>
++++++++++++++++++++++
++ httpd_perl.conf - end      ++
++++++++++++++++++++++
##################
##  startup.pl - start ##
##################
 #!perl
 
 unless (defined $ENV{MOD_PERL}) {
     die "\$ENV{MOD_PERL} not set!";
 }
 
 use Apache::Constants ();
   
 sub My::ProxyRemoteAddr ($) {
     my $r = shift;
    
     # we'll only look at the X-Forwarded-For header if the requests
     # comes from our proxy at localhost
     
     return Apache::Constants::OK 
         unless ($r->connection->remote_ip eq "127.0.0.1") 
             and $r->header_in('X-Forwarded-For');
   
     # Select last value in the chain -- original client's ip
     if (my ($ip) = $r->headers_in->{'X-Forwarded-For'} =~ /([^,\s]+)$/) {
       $r->connection->remote_ip($ip);
     }
         
     return Apache::Constants::OK;
   }
 1;
##################
##  startup.pl -end   ##
##################
##########################
##  ProxyRemoteAddr - start  ##
##########################
 package Book::ProxyRemoteAddr;
 
 use Apache::Constants qw(OK);
 use strict;
 
 sub handler {
     my $r = shift;
 
     # we'll only look at the X-Forwarded-For header if the request
     # comes from our proxy at localhost
     return OK unless ($r->connection->remote_ip eq "127.0.0.1") &&
         $r->header_in('X-Forwarded-For');
 
     # Select last value in the chain -- original client's IP
     if (my ($ip) = $r->headers_in->{'X-Forwarded-For'} =~ /([^,\s]+)$/) {
         $r->connection->remote_ip($ip);
     }
 
     return OK;
 }
 1;
##########################
##  ProxyRemoteAddr - end   ##
##########################



---------------------------------
Post your free ad now! Yahoo! Canada Personals

Mime
View raw message