You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Carlos Ramirez <cr...@gte.net> on 2002/08/07 07:32:36 UTC

Catching CGI output for rewriting

Is it possible to have a mod_perl handler catch the output of CGI 
scripts (in Perl, C, etc) to rewrite content before is gets sent out to 
the browser, specifically to re-write urls within the generated pages. 
This is very similar to the recent post titled: "Question re: Session 
mgmt using mod_perl...", but with a twist.

The easy part was writing the handler to rewrite urls within static 
pages via
  Apache::OutpuChain Apache::myReverseProxySafeLinks Apache::PassHtml.

Now the tricky, if not impossible part of the task is to pass CGI 
scripts (C/Perl web apps) through my handler to rewrite urls generated 
within the CGI scripts to conform to our reverse proxy rules. After 
messing around abit, I figured that the only way to accomplish this is 
by having the handler call the script via LWP and get the result. Has 
anyone tried this before? The main concern is fetching CGI requests 
within the handler that include submitted form data.

Pseudo process:
browser_request->reverse_proxy->internal_webserver->myhandler->
  ->myhandler: do_lwp_fetch_to_requested_cgi->
  ->myhandler: rewrite_urls_within_output->
  ->send_to_back_to_proxy->send_to_browser

btw, i'm using Apache 1.3.26/mod_perl_1.26/Solaris8/perl5.6.1. I think 
this is possible in Apache2.0, but too bad we're not there yet ;)

Thanks in advance,

-Carlos