Thanks in advance. I've tried all the archives and google'd but I have not found anything that would help.

 

I'm running RH 8.0, httpd-2.0.40-11.5 and mod_perl-1.99_05-3 from the RedHat distribution. I'm trying to create a small proxy module that will check a non-proxy request and depending on "stuff" dynamically transform it into a proxy request using mod_proxy.

 

 

I'm following the example in Chapter 7 (page 370) of the "Writing Apache Modules with Perl and C". I know that the book is based on the older apache 1.3 server and associated mod_perl. However, I have not found anything in my readings to indicate that this would not work any more.

 

My version of the proxy module from the book is :

 

package ProxyTest;

 

use strict;

 

use warnings;

 

use Apache::RequestRec (); # for $r->content_type

 

use Apache::Const -compile =3D> 'OK';

 

use Apache::Const -compile =3D> 'DECLINED';

 

#use Apache::RequestUtil ();

 

sub handler

 

{

 

    my $r =3D shift;

 

    return Apache::DECLINED if $r->proxyreq;

 

    # set proxy to true

 

    $r->proxyreq(1);

 

    my $uri =3D $r->uri;

 

    # reset URI for mod_proxy

 

    my $newUri =3D 'http://test/goodbye.html';

 

    $r->uri($newUri);

 

    $r->filename("proxy:$newUri");

 

    # change handler to mod_proxy

 

    $r->handler('proxy-server');

 

    return Apache::OK;

 

}

 

1;

 

When I hit the "test" server, I fail with:

 

Proxy Error

 

 

The proxy server received an invalid response from an upstream server. The proxy server could not handle the request GET http://test/goodbye.html.=20

 

Reason: Max-Forwards has reached zero - proxy loop?

 

Additionally, a 502 Bad Gateway error was encountered while trying to use an ErrorDocument to handle the request.

 

The apache error log indicates (with some debugging) that it is looping on the "GET" of goodbye.html. Additional debuging indicates that $r->proxyreq is always 0, so it's looping. My questions are:

 

1.    Did sometime change in apache 2 or mod_perl 2 so that you cannot

set proxyreq anymore: ie. $r->proxyreq(1).

2.    How do you set proxyreq if $r->proxyreq(1) is not the correct

method?

3.    Is the logic wrong in this proxy example?

 

Thanks again. Any help is appreciated.

 

John

Reply via email to