Loading ...
Sorry, an error occurred while loading the content.
 

the scripts under mod_perl are running as mod_cgi

Expand Messages
  • SHAHNAWAZ OSMAN
    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
    Message 1 of 11 , Dec 1, 2004
      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@...
       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
    • Stas Bekman
      ... [...] ... it should be: ProxyPass /perl/ http://localhost:8000/perl/ ProxyPassReverse /perl/ http://localhost:8000/perl/ ... [...] ... --
      Message 2 of 11 , Dec 1, 2004
        SHAHNAWAZ OSMAN wrote:
        > 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...
        [...]
        > ProxyPass /perl/ http://localhost:8000/cgi-bin/
        > ProxyPassReverse /perl/ http://localhost:8000/cgi-bin/

        it should be:

        ProxyPass /perl/ http://localhost:8000/perl/
        ProxyPassReverse /perl/ http://localhost:8000/perl/

        > Here is the backend config file for mod_perl enabled server...
        [...]
        > Alias /perl/ /home/user-name/public_html/cgi-bin/
        > <Location /perl>



        --
        __________________________________________________________________
        Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
        http://stason.org/ mod_perl Guide ---> http://perl.apache.org
        mailto:stas@... http://use.perl.org http://apacheweek.com
        http://modperlbook.org http://apache.org http://ticketmaster.com

        --
        Report problems: http://perl.apache.org/bugs/
        Mail list info: http://perl.apache.org/maillist/modperl.html
        List etiquette: http://perl.apache.org/maillist/email-etiquette.html
      • SHAHNAWAZ OSMAN
        Hi Stas, Thank you for your speedy response. Now, when I try to run the script (http://www.mydoamin.com/perl/test.pl) I get a 404 - file not found page and
        Message 3 of 11 , Dec 1, 2004
          Hi Stas,


          Thank you for your speedy response. Now, when I try to
          run the script
          (http://www.mydoamin.com/perl/test.pl) I get a "404 -
          file not found page"
          and get the following message in the error log.

          "/usr/local/httpd_perl/cgi-bin/test.pl not found or
          unable to stat"

          I was getting this message until I changed the proxy
          setting and added another
          line (ScriptAlias /cgi-bin/
          /home/user-name/public_html/cgi-bin/) in my backend
          server configuration file.

          Could you please give me some idea what needs to done
          now? Here is my revised config
          files. Thank you in advance for your cooperation.

          +++++++++++++++++++++++++++++
          +++++++++++++++++++++++++++++
          ++ httpd_perl.conf - start ++
          ++ (backend) ++
          +++++++++++++++++++++++++++++
          +++++++++++++++++++++++++++++


          BindAddress 127.0.0.1

          port 8000

          # add the folloing lines at the bottom of your
          configuration file:

          ##### mod_perl settings#####

          PerlRequire
          /usr/local/perl_server/conf/startup.pl
          PerlFixupHandler Apache::SizeLimit
          PerlPostReadRequestHandler Book::ProxyRemoteAddr
          PerlSetupEnv Off


          Listen 8000
          <VirtualHost localhost:8000>
          ServerAlias www.mydomain.com mydomain.com
          ServerAdmin webmaster@...
          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>
          # AllowOverride None
          SetHandler perl-script
          PerlHandler Apache::Registry
          Options ExecCGI
          PerlSendHeader On
          Allow from all
          </Location>
          </VirtualHost>

          +++++++++++++++++++++++++++
          +++++++++++++++++++++++++++
          ++ httpd_perl.conf - end ++
          ++ (backend) ++
          +++++++++++++++++++++++++++
          +++++++++++++++++++++++++++


          ++++++++++++++++++++++++
          ++++++++++++++++++++++++
          ++ httpd.conf - start ++
          ++ (frontend) ++
          ++++++++++++++++++++++++
          ++++++++++++++++++++++++

          # I added the following lines at the 'LoadModule'
          section

          LoadModule proxy_add_forward_module
          libexec/mod_proxy_add_forward.so
          LoadModule proxy_module
          libexec/mod_proxy.so

          # and added the following lines at the 'AddModule'
          section

          AddModule mod_proxy_add_forward.c
          AddModule mod_proxy.c

          # this is the proxy setting as per your sugggestion

          <IfModule mod_proxy.c>
          ProxyRequests On
          ProxyPass /perl/ http://localhost:8000/perl/
          ProxyPassReverse /perl/ http://localhost:8000/perl/
          </ifModule>

          # this is the exact setting of my VirtualHost


          <VirtualHost xx.xx.xx.xxx>
          ServerAlias www.mydomain.com mydomain.com
          ServerAdmin webmaster@...
          DocumentRoot /home/user-name/public_html
          BytesLog domlogs/mydomain.com-bytes_log
          <IfModule mod_userdir.c>
          UserDir disabled
          UserDir enabled user-name
          </IfModule>
          ServerName www.mydomain.com

          ### this is the only line I added here...####

          Alias /perl/ /home/maium/public_html/cgi-bin/

          ###### ###### ###### ###### ######

          ScriptAlias /cgi-bin/
          /home/maium/public_html/cgi-bin/

          # I tried this way and it didn't work. So, I comment
          it out.

          # RewriteEngine on
          # RewriteOptions 'inherit'
          # RewriteRule ^/(perl/.*)$
          http://127.0.0.1:8000/perl/$1 [P,L]
          # ProxyPassReverse /
          http://www.infoquestusainc.net/perl

          <IfModule mod_php4.c>
          php_admin_value open_basedir
          "/home/user-name:/usr/lib/php:/usr/local/lib/php:/tmp"
          </IfModule>
          User user-name
          Group user-name
          CustomLog domlogs/mydomain.com combined

          </VirtualHost>


          +++++++++++++++++++++++
          +++++++++++++++++++++++
          ++ httpd.conf - end ++
          ++ (frontend) ++
          +++++++++++++++++++++++
          +++++++++++++++++++++++







          --- Stas Bekman <stas@...> wrote:
          > SHAHNAWAZ OSMAN wrote:
          > > 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...
          > [...]
          > > ProxyPass /perl/ http://localhost:8000/cgi-bin/
          > > ProxyPassReverse /perl/
          > http://localhost:8000/cgi-bin/
          >
          > it should be:
          >
          > ProxyPass /perl/ http://localhost:8000/perl/
          > ProxyPassReverse /perl/ http://localhost:8000/perl/
          >
          > > Here is the backend config file for mod_perl
          > enabled server...
          > [...]
          > > Alias /perl/ /home/user-name/public_html/cgi-bin/
          > > <Location /perl>
          >
          >
          >
          > --
          >
          __________________________________________________________________
          > Stas Bekman JAm_pH ------> Just Another
          > mod_perl Hacker
          > http://stason.org/ mod_perl Guide --->
          > http://perl.apache.org
          > mailto:stas@... http://use.perl.org
          > http://apacheweek.com
          > http://modperlbook.org http://apache.org
          > http://ticketmaster.com
          >
          > --
          > Report problems: http://perl.apache.org/bugs/
          > Mail list info:
          > http://perl.apache.org/maillist/modperl.html
          > List etiquette:
          > http://perl.apache.org/maillist/email-etiquette.html
          >
          >

          ______________________________________________________________________
          Post your free ad now! http://personals.yahoo.ca

          --
          Report problems: http://perl.apache.org/bugs/
          Mail list info: http://perl.apache.org/maillist/modperl.html
          List etiquette: http://perl.apache.org/maillist/email-etiquette.html
        • Stas Bekman
          ... Then your configuration on the backend is wrong. Do you have symlinks or something that redirects /home/user-name/public_html/cgi-bin/ to
          Message 4 of 11 , Dec 1, 2004
            SHAHNAWAZ OSMAN wrote:
            > Hi Stas,
            >
            >
            > Thank you for your speedy response. Now, when I try to
            > run the script
            > (http://www.mydoamin.com/perl/test.pl) I get a "404 -
            > file not found page"
            > and get the following message in the error log.
            >
            > "/usr/local/httpd_perl/cgi-bin/test.pl not found or
            > unable to stat"
            >
            > I was getting this message until I changed the proxy
            > setting and added another
            > line (ScriptAlias /cgi-bin/
            > /home/user-name/public_html/cgi-bin/) in my backend
            > server configuration file.

            Then your configuration on the backend is wrong. Do you have symlinks or
            something that redirects /home/user-name/public_html/cgi-bin/ to
            /usr/local/httpd_perl/cgi-bin/.

            The simplest way to debug the backend is to access it directly first i.e.
            yourbackendserver:8000/perl/... make it working and only then move on to
            the front end config.

            p.s. please truncate the parts you don't reply to. No point leaving long
            useless tails.

            --
            __________________________________________________________________
            Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
            http://stason.org/ mod_perl Guide ---> http://perl.apache.org
            mailto:stas@... http://use.perl.org http://apacheweek.com
            http://modperlbook.org http://apache.org http://ticketmaster.com

            --
            Report problems: http://perl.apache.org/bugs/
            Mail list info: http://perl.apache.org/maillist/modperl.html
            List etiquette: http://perl.apache.org/maillist/email-etiquette.html
          • INFOQUEST USA INC.
            Stas is right. You have a problem in your httpd.conf file. Check the section ... ... you probably have a line ScriptAlias
            Message 5 of 11 , Dec 2, 2004
              Stas is right. You have a problem in your httpd.conf file. Check the section
              :

              <IfModule mod_alias.c>
              ...
              </IfModule>

              you probably have a line

              ScriptAlias /cgi-bin/ /usr/local/http_perl/cgi-bin/

              change is to":

              Alias /perl/ /home/user-name/public_html/cgi-bin/

              and also if you have the following line:

              <Directory "/usr/local/http_perl/cgi-bin">

              change it to

              <Directory "/usr/local/http_perl/perl">

              You should be able to up and running in no time. I learnt it the hard way.
              If this doesn't work then post your backend http.conf file here. Guru Stas
              is here and you will certainly get a solution. I would like to Thank Stas
              for his contribution in this community. I learnt most of the things from his
              book - 'Practical mod_perl'.


              Khalid Shawkat

              _________________________________________________________________
              Don�t just search. Find. Check out the new MSN Search!
              http://search.msn.click-url.com/go/onm00200636ave/direct/01/


              --
              Report problems: http://perl.apache.org/bugs/
              Mail list info: http://perl.apache.org/maillist/modperl.html
              List etiquette: http://perl.apache.org/maillist/email-etiquette.html
            • Stas Bekman
              ... right. ... probably not, since /usr/local/http_perl/perl doesn t exist. ... -- __________________________________________________________________ Stas
              Message 6 of 11 , Dec 2, 2004
                INFOQUEST USA INC. wrote:
                > Stas is right. You have a problem in your httpd.conf file. Check the
                > section :
                >
                > <IfModule mod_alias.c>
                > ...
                > </IfModule>
                >
                > you probably have a line
                >
                > ScriptAlias /cgi-bin/ /usr/local/http_perl/cgi-bin/
                >
                > change is to":
                >
                > Alias /perl/ /home/user-name/public_html/cgi-bin/

                right.

                > and also if you have the following line:
                >
                > <Directory "/usr/local/http_perl/cgi-bin">
                >
                > change it to
                >
                > <Directory "/usr/local/http_perl/perl">

                probably not, since "/usr/local/http_perl/perl" doesn't exist.

                > You should be able to up and running in no time. I learnt it the hard
                > way. If this doesn't work then post your backend http.conf file here.
                > Guru Stas is here and you will certainly get a solution. I would like to
                > Thank Stas for his contribution in this community. I learnt most of the
                > things from his book - 'Practical mod_perl'.

                :) Thanks for the kind words, Khalid

                --
                __________________________________________________________________
                Stas Bekman JAm_pH ------> Just Another mod_perl Hacker
                http://stason.org/ mod_perl Guide ---> http://perl.apache.org
                mailto:stas@... http://use.perl.org http://apacheweek.com
                http://modperlbook.org http://apache.org http://ticketmaster.com

                --
                Report problems: http://perl.apache.org/bugs/
                Mail list info: http://perl.apache.org/maillist/modperl.html
                List etiquette: http://perl.apache.org/maillist/email-etiquette.html
              • SHAHNAWAZ OSMAN
                I have those lines in my http.conf in mod_alias section and I changed those as per your suggestion but still it s not working.
                Message 7 of 11 , Dec 2, 2004
                  I have those lines in my http.conf in mod_alias
                  section and I changed those as per your suggestion but
                  still it's not working.

                  ______________________________________________________________________
                  Post your free ad now! http://personals.yahoo.ca

                  --
                  Report problems: http://perl.apache.org/bugs/
                  Mail list info: http://perl.apache.org/maillist/modperl.html
                  List etiquette: http://perl.apache.org/maillist/email-etiquette.html
                • SHAHNAWAZ OSMAN
                  Sorry, I guess I spoke too soon. I didn t see the next message from Stas. I just created a directory (mkdir /usr/local/httpd_perl/perl) and it s working!!!
                  Message 8 of 11 , Dec 2, 2004
                    Sorry, I guess I spoke too soon. I didn't see the next
                    message from Stas. I just created a directory (mkdir
                    /usr/local/httpd_perl/perl) and it's working!!! Thanks
                    to Stas and Khalid both of you. Now, my
                    Authen::Captcha is not working under mod_perl. Is it a
                    bug or it's just a bad code? Thanks again...


                    Osman

                    ______________________________________________________________________
                    Post your free ad now! http://personals.yahoo.ca

                    --
                    Report problems: http://perl.apache.org/bugs/
                    Mail list info: http://perl.apache.org/maillist/modperl.html
                    List etiquette: http://perl.apache.org/maillist/email-etiquette.html
                  • INFOQUEST USA INC
                    I am glad that your installtion is successful. I would suggest you to buy some books specially Practical modperl by Stas. You can always ask the author here,
                    Message 9 of 11 , Dec 3, 2004
                      I am glad that your installtion is successful. I would suggest you to buy
                      some books specially 'Practical modperl" by Stas. You can always ask the
                      author here, if you need any help, which I consider a rare opportunity. By
                      the way, Authen::Captcha has some problem with mod_perl. Check the link
                      here: http://www.perlmonks.org/index.pl?node_id=336882. I think that you
                      also need to disable mod_gzip (if it is installed) when using proxy or ssl.
                      I am going to design a auto-installer for mod_perl as many of my customers
                      is not comfortable installing it. I will post it here soon.

                      Khalid


                      --
                      Report problems: http://perl.apache.org/bugs/
                      Mail list info: http://perl.apache.org/maillist/modperl.html
                      List etiquette: http://perl.apache.org/maillist/email-etiquette.html
                    • INFOQUEST USA INC
                      You are very welcome Stas. Thank you for pointing out the directory issue. Your book really helped me a lot and I truely believe that people like you are the
                      Message 10 of 11 , Dec 3, 2004
                        You are very welcome Stas. Thank you for pointing out the directory issue.
                        Your book really helped me a lot and I truely believe that people like you
                        are the engines of this open source community. I am sure that many feels the
                        same way.

                        Khalid

                        --
                        Report problems: http://perl.apache.org/bugs/
                        Mail list info: http://perl.apache.org/maillist/modperl.html
                        List etiquette: http://perl.apache.org/maillist/email-etiquette.html
                      • Michael Peters
                        ... you should really check out ApacheToolBox (http://apachetoolbox.com/). It s really easy to use to install apache/mod_perl/php, and a whole bunch of other
                        Message 11 of 11 , Dec 3, 2004
                          INFOQUEST USA INC wrote:

                          > I am going to design a auto-installer for mod_perl as many of my customers
                          > is not comfortable installing it. I will post it here soon.

                          you should really check out ApacheToolBox (http://apachetoolbox.com/).
                          It's really easy to use to install apache/mod_perl/php, and a whole
                          bunch of other modules. The only drawback is that it doesn't work for
                          apache2/mod_perl2 yet.

                          --
                          Michael Peters
                          Developer
                          Plus Three, LP


                          --
                          Report problems: http://perl.apache.org/bugs/
                          Mail list info: http://perl.apache.org/maillist/modperl.html
                          List etiquette: http://perl.apache.org/maillist/email-etiquette.html
                        Your message has been successfully submitted and would be delivered to recipients shortly.