You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by petersm <pe...@venzia.com> on 2004/03/05 16:30:28 UTC

Proxy Config

Greetings,

Using Fedora Core 1
Apache 1.3.29
mod_perl 1.29

Aparently I am just not understanding something and would like to ask this
list for some help. I'm trying to set up a non-mod_perl proxy server as the
front end which would then forward requests for certain files of certain
applications to the back-end mod_perl enabled apache. I've set up the front
end apache (which I just named 'apache') with mod_proxy, mod_rewrite, and
mod_proxy_add_forward following after the example in
http://perl.apache.org/docs/1.0/guide/scenario.html#Building_the_httpd_perl_Server
(thanks Stas for the docs). I then set up the back-end (which I named
'apache_perl'). Both start up just fine and the front end serves ordinay files
and plain CGI scripts just fine. It even appears to forward the matching test
mod_perl requests to the back-end server. The problem is that I get a '500
internal Server Error' and no entry in the error logs for the back-end. I'm
pretty sure the back-end server is getting the requests cause the error
message on the screen shows this message on the bottom 
'Apache/1.3.29 Server at 127.0.0.1 Port 8181' and that is the name of my
back-end server (127.0.0.1) not the front-end and that's the port I have it
running on. When I start up the apache_perl server the info gets printed to
the correct error log, but not the error generated when I try and run the test
script. I don't know exactly where to go from here since I can't tell why the
script is generating the error. Here are the relevant portions of my conf files

apache/conf/httpd.conf
[snip]

ErrorLog /usr/local/apache/logs/error_log

RewriteEngine     on
RewriteRule       ^/(intranet/.*\.cgi)$  http://127.0.0.1:8181/$1   [P,L]
NoCache           *
ProxyPassReverse  /  http://extranet.venzia.com/

[/snip]


apache_perl/conf/httpd.conf
[snip]
  ServerName 127.0.0.1 
  Port 8181
  ErrorLog /usr/local/apache_perl/logs/error_log
  LogLevel warn

  PerlRequire /usr/local/apache_perl/conf/startup.pl
  PerlPostReadRequestHandler My::ProxyRemoteAddr
  PerlModule Apache::Registry

  <Location /intranet>    
    DirectoryIndex index.cgi index.html
    SetHandler perl-script
    PerlHandler Apache::Registry
    Options ExecCGI
    allow from all
    PerlSendHeader On
    PerlSetEnv PERL5LIB /development
  </Location>
[/snip]



apache_perl/conf/starup.pl


#!/usr/bin/perl
 
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');
}
 
1;


Any help would be appreciated.
Thanks

Michael Peters
Venzia





-- 
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


Re: Proxy Config

Posted by "Charles C. Fu" <pe...@mail.web-i18n.net>.
In <20...@venzia.com> on 05 Mar 2004,
   petersm  <pe...@venzia.com> wrote:
>> RewriteRule       ^/(intranet/.*\.cgi)$  http://127.0.0.1:8181/$1   [P,L]

> 68.52.48.147 - - [05/Mar/2004:10:16:23 -0600]
> [extranet.venzia.com/sid#a0a904c][rid#a0c690c/initial] (1) go-ahead with proxy
> request proxy:http://127.0.0.1:8080/intranet/www/index.cgi [OK]

The port numbers don't match.  Was that a typo or a change in
configuration you didn't mention?

-ccwf
-- 
Charles C. Fu
Founder
Web i18n, LLC
www.web-i18n.net

-- 
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


Re: Proxy Config

Posted by petersm <pe...@venzia.com>.
Just as a follow-up incase anyone was trying to help me. 

If I change the rewrite rule to send .html and .cgi it fails as well.

If I stop the front-end 'apache' and then change the 'apache_perl' to run on
port 80, it serves up the page just fine. It just doesn't work if the
front-end proxy is on and 'apache_perl' is the back-end.

Adding the logging of the rewrite rule using the following config lines
[snip]
 RewriteLogLevel 1
 RewriteLog "| /usr/local/apache/bin/rotatelogs \
   /usr/local/apache_perl/logs/r_log 86400"
[/snip]

will create entries in that log file that look like this...
[snip]
68.52.48.147 - - [05/Mar/2004:10:16:23 -0600]
[extranet.venzia.com/sid#a0a904c][rid#a0c690c/initial] (1) go-ahead with proxy
request proxy:http://127.0.0.1:8080/intranet/www/index.cgi [OK]
[/snip]

which makes me think that the rewrite is taking place fine. Somehow, when the
back-end 'apache_perl' recieves the request something is going wrong and it's
not logging it (or at least no where I'm looking)

Any help?
thanks,
Michael Peters
Venzia


---------- Original Message -----------
From: "petersm" <pe...@venzia.com>
To: "mod_perl list" <mo...@perl.apache.org>
Sent: Fri, 5 Mar 2004 10:30:28 -0500
Subject: Proxy Config

> Greetings,
> 
> Using Fedora Core 1
> Apache 1.3.29
> mod_perl 1.29
> 
> Aparently I am just not understanding something and would like to ask this
> list for some help. I'm trying to set up a non-mod_perl proxy server as the
> front end which would then forward requests for certain files of certain
> applications to the back-end mod_perl enabled apache. I've set up the front
> end apache (which I just named 'apache') with mod_proxy, mod_rewrite, and
> mod_proxy_add_forward following after the example in
>
http://perl.apache.org/docs/1.0/guide/scenario.html#Building_the_httpd_perl_Server
> (thanks Stas for the docs). I then set up the back-end (which I named
> 'apache_perl'). Both start up just fine and the front end serves ordinay files
> and plain CGI scripts just fine. It even appears to forward the matching test
> mod_perl requests to the back-end server. The problem is that I get a '500
> internal Server Error' and no entry in the error logs for the back-end. I'm
> pretty sure the back-end server is getting the requests cause the error
> message on the screen shows this message on the bottom 
> 'Apache/1.3.29 Server at 127.0.0.1 Port 8181' and that is the name of my
> back-end server (127.0.0.1) not the front-end and that's the port I have it
> running on. When I start up the apache_perl server the info gets printed to
> the correct error log, but not the error generated when I try and run the test
> script. I don't know exactly where to go from here since I can't tell why the
> script is generating the error. Here are the relevant portions of my conf files
> 
> apache/conf/httpd.conf
> [snip]
> 
> ErrorLog /usr/local/apache/logs/error_log
> 
> RewriteEngine     on
> RewriteRule       ^/(intranet/.*\.cgi)$  http://127.0.0.1:8181/$1   [P,L]
> NoCache           *
> ProxyPassReverse  /  http://extranet.venzia.com/
> 
> [/snip]
> 
> apache_perl/conf/httpd.conf
> [snip]
>   ServerName 127.0.0.1 
>   Port 8181
>   ErrorLog /usr/local/apache_perl/logs/error_log
>   LogLevel warn
> 
>   PerlRequire /usr/local/apache_perl/conf/startup.pl
>   PerlPostReadRequestHandler My::ProxyRemoteAddr
>   PerlModule Apache::Registry
> 
>   <Location /intranet>    
>     DirectoryIndex index.cgi index.html
>     SetHandler perl-script
>     PerlHandler Apache::Registry
>     Options ExecCGI
>     allow from all
>     PerlSendHeader On
>     PerlSetEnv PERL5LIB /development
>   </Location>
> [/snip]
> 
> apache_perl/conf/starup.pl
> 
> #!/usr/bin/perl
>  
> 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');
> }
>  
> 1;
> 
> Any help would be appreciated.
> Thanks
> 
> Michael Peters
> Venzia
> 
> -- 
> 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
------- End of Original Message -------


-- 
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