Return-Path: Delivered-To: apmail-perl-modperl-archive@www.apache.org Received: (qmail 86786 invoked from network); 24 Mar 2009 12:10:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 24 Mar 2009 12:10:40 -0000 Received: (qmail 68587 invoked by uid 500); 24 Mar 2009 12:03:19 -0000 Delivered-To: apmail-perl-modperl-archive@perl.apache.org Received: (qmail 68560 invoked by uid 500); 24 Mar 2009 12:03:19 -0000 Mailing-List: contact modperl-help@perl.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Delivered-To: mailing list modperl@perl.apache.org Received: (qmail 68552 invoked by uid 99); 24 Mar 2009 12:03:19 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Mar 2009 12:03:19 +0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests=SPF_PASS,WHOIS_NETSOLPR X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: local policy) Received: from [193.226.116.136] (HELO pony.netsoft.ro) (193.226.116.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 24 Mar 2009 12:03:09 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by pony.netsoft.ro (8.14.3/8.14.3) with ESMTP id n2OC2JWQ011613; Tue, 24 Mar 2009 14:02:19 +0200 Date: Tue, 24 Mar 2009 14:02:19 +0200 (EET) From: Iosif Fettich Reply-To: ifettich@netsoft.ro To: Torsten Foertsch cc: modperl@perl.apache.org Subject: Re: who's putting that
 tag in the output...?
In-Reply-To: <200903231959.56770.torsten.foertsch@gmx.net>
Message-ID: 
References: <4e2034060903061031y51bafd58yd5d796264b2d5595@mail.gmail.com>
 
 
 <200903231959.56770.torsten.foertsch@gmx.net>
User-Agent: Alpine 2.00 (LFD 1167 2008-08-23)
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; format=flowed; charset=US-ASCII
X-Virus-Checked: Checked by ClamAV on apache.org

Hi Torsten,

> An ErrorDocument is an internal redirect. These REDIRECT_... environment 
> variables are copied from the previous ($r->prev) request's 
> $r->subprocess_env just by copying everything and prepending REDIRECT_ 
> to each key. So if the original request has an environment variable 
> named REQUEST_URI the error document should have a REDIRECT_REQUEST_URI, 
> see rename_original_env() in httpd-x.y/modules/http/http_request.c.
>
> Since REQUEST_URI is the standard CGI environment variable (see
> ap_add_cgi_vars() httpd-x.y/server/util_script.c) I'd take
> REDIRECT_REQUEST_URI.

As it turned out, I was (entirely) wrong when I thought it is 
working. It was wishfull thinking - but not a real solution - neighter one 
of the REQUEST_URI, REDIRECT_URL and/or REDIRECT_QUERY_STRING environment 
variables seemed to be good enough for a mod_rewrite solution, or at least 
I was unable to build one. (I just made some errors in testing and 
repeatedly out- and out-out-commenting various httpd.conf setting, but it 
wasn't _really_ working whein I thought it would).

Summing up what I have so far ( which might be incomplete or even wrong):

looking for a cheap/good/working solution for a way to solve what

http://httpd.apache.org/docs/2.2/rewrite/rewrite_guide_advanced.html

describes under the title "Redirect Failing URLs to Another Web Server", 
but with the (it seems important) difference that I want to hide the new 
server from the eyes of the customers and as such _proxy_ the failing 
requests instead of redirecting, the given receipt

RewriteEngine on
RewriteCond   %{REQUEST_URI} !-U
RewriteRule   ^(.+)          http://webserverB.dom/$1

shows up to NOT work when I attempted to make it

RewriteEngine on
RewriteCond   %{REQUEST_URI} !-U
RewriteRule   ^(.+)          http://webserverB.dom/$1 [P]

Neither was I able to use the Error_Document trick you sugegsted and use 
Rewrite on/with it.

I've given up my first attempt - the earlier in the thread shown 
PerlResponse handler - as I was unable to output the Content-Type header 
as 'text/html'; I haven't however tried the solution suggested with adding 
an extra filter for the end phase to substitute the 'text/plain' that I 
was seeing and which actually generated the initial question for this 
thread and it's subject.

I finally went the 'standard way' [?]  and added

ErrorDocument 404  /cgi-bin/404_to_oldserver.pl

in httpd.conf, making /cgi-bin/404_to_oldserver.pl to be

----------------------------
#!/usr/bin/perl

use LWP::UserAgent;

my $ua = LWP::UserAgent->new;

my $url = $ENV{'REQUEST_URI'};
    $url = "http://OLD.SERVER.COM/$url" ;

my $response = $ua->get( $url );

my $body = $response->content;

my $h = $response->{'_headers'};
    $h->push_header( 'Status' => $response->code );
my $header = $h->as_string;

print $header;
print "\n";
print $body;

1;
-----------------------------------------------

This way might have it's own special problems too, but at least it seems 
to work OK so far and give me a start.

I'm still [a bit] convinced that a mod_perl solution might or should be 
available and be both better and more effective, but I wasn't able to get 
it working - even after spending much more effort than I thought initially 
that it will take - and gave up for now.

Many thanks to all those that offered advice or help.

Iosif Fettich

PS. Firebug once again proved to be an invaluable resource in helping 
understand what's up and find a solution.