I am running Apache/2.0.48 (Win32) mod_perl/1.99_13 Perl/v5.8.0 on Windows XP.
I've downloaded the Apache binary from http://hunter.campbus.com/, and have tried IBM httpd 2.047 as well. mod perl and Apache::Clean I have installed using perl ppm. My perl is from ActivePerl.
I have written a OutputFilter that finds a string in a response and replaces the string with another. It works fine with static files, but not on response from a reverse proxy, and that is just what I want to achieve. I'm trying to run my Outlook Web Access backend behind an Apache frontend.
Running Apache::Clean for instance does work on reverse proxied content, it seems.
In my error log I see:
[Mon Mar 22 15:33:31 2004] [info] Mike:filter.pm(43): mapping for /index.html (an HTML document)
[Mon Mar 22 15:33:31 2004] [info] Exiting Mike:filter.pm
[Mon Mar 22 15:33:31 2004] [info] Mike:filter.pm(29): skipping request to /rowan.jpg (not an HTML document)
[Mon Mar 22 15:33:31 2004] [info] Exiting Mike:filter.pm
[Mon Mar 22 15:33:48 2004] [info] Mike:filter.pm(43): mapping for /index.html (an HTML document)
[Mon Mar 22 15:33:48 2004] [info] Exiting Mike:filter.pm
[Mon Mar 22 15:33:48 2004] [info] Mike:filter.pm(29): skipping request to /rowan.jpg (not an HTML document)
[Mon Mar 22 15:33:48 2004] [info] Exiting Mike:filter.pm
[Mon Mar 22 15:33:53 2004] [debug] proxy_http.c(109): proxy: HTTP: canonicalising URL //mda.demon.nl:86/exchange/
[Mon Mar 22 15:33:53 2004] [debug] mod_proxy.c(459): Trying to run scheme_handler
[Mon Mar 22 15:33:54 2004] [debug] proxy_http.c(1076): proxy: HTTP: serving URL http://mda.demon.nl:86/exchange/
[Mon Mar 22 15:33:54 2004] [debug] proxy_http.c(221): proxy: HTTP connecting http://mda.demon.nl:86/exchange/ to mda.demon.nl:86
[Mon Mar 22 15:33:54 2004] [debug] proxy_util.c(1203): proxy: HTTP: fam 2 socket created to connect to mda.demon.nl
[Mon Mar 22 15:33:54 2004] [debug] proxy_http.c(370): proxy: socket is connected
[Mon Mar 22 15:33:54 2004] [debug] proxy_http.c(404): proxy: connection complete to 212.238.156.229:86 (mda.demon.nl)
[Mon Mar 22 15:33:54 2004] [debug] proxy_http.c(917): proxy: start body send
[Mon Mar 22 15:33:54 2004] [info] Mike:filter.pm(43): mapping for /exchange/ (an HTML document)
[Mon Mar 22 15:33:54 2004] [info] Exiting Mike:filter.pm
Free to wrong pool 81a5a0 not 8f5cb0.
[Mon Mar 22 15:33:59 2004] [notice] Parent: child process exited with status 3221225477 -- Restarting.
[Mon Mar 22 15:34:00 2004] [notice] Parent: Created child process 4496
[Mon Mar 22 15:34:00 2004] [debug] mpm_winnt.c(505): Parent: Sent the scoreboard to the child
[Mon Mar 22 15:34:00 2004] [notice] Child 4496: Child process is running
[Mon Mar 22 15:34:00 2004] [debug] mpm_winnt.c(426): Child 4496: Retrieved our scoreboard from the parent.
[Mon Mar 22 15:34:00 2004] [info] Parent: Duplicating socket 184 and sending it to child process 4496
[Mon Mar 22 15:34:00 2004] [debug] mpm_winnt.c(623): Parent: Sent 1 listeners to child 4496
[Mon Mar 22 15:34:00 2004] [debug] mpm_winnt.c(582): Child 4496: retrieved 1 listeners from parent
[Mon Mar 22 15:34:00 2004] [notice] Child 4496: Acquired the start mutex.
[Mon Mar 22 15:34:00 2004] [notice] Child 4496: Starting 25 worker threads.
[Mon Mar 22 15:34:00 2004] [debug] child.c(695): Child 4496: Worker thread 0 starting.
[Mon Mar 22 15:34:00 2004] [debug] child.c(695): Child 4496: Worker thread 1 starting.
[Mon Mar 22 15:34:00 2004] [debug] child.c(695): Child 4496: Worker thread 2 starting.
httpd.conf contains:
<VirtualHost *:81> ServerName mail.franken.ws DocumentRoot e:/www/docs/rowan.kueper.org/ ProxyPass /exchange http://backend:86/exchange ProxyPassReverse /exchange http://backend:86/exchange ProxyPass /exchweb http://backend:86/ExchWeb ProxyPassReverse /exchweb http://backend:86/ExchWeb ProxyPass /public http://backend:86/public ProxyPassReverse /public http://backend:86/public PerlModule Apache2 PerlModule Mike::Filter <Location /> SetHandler modperl PerlOutputFilterHandler Mike::Filter PerlSetVar FilterSource backend:86 PerlAddVar FilterDestination frontend:81 </Location> </VirtualHost>
Filter: package Mike::Filter;
#inspired by Apache::Clean filter use 5.008;
use Apache::Filter (); # $f use Apache::RequestRec (); # $r use Apache::RequestUtil (); # $r->dir_config() use Apache::Log (); # $log->info() use APR::Table (); # dir_config->get() and headers_out->get()
use Apache::Const -compile => qw(OK DECLINED);
use strict;
use constant BUFF_LEN => 1024;
sub handler { my $f = shift;
my $r = $f->r;
my $log = $r->server->log;
# only process HTML documents
unless ($r->content_type =~ m!text/html!i) {
$log->info('Mike:filter.pm(29): skipping request to ', $r->uri, ' (not an HTML document)');
$log->info('Exiting Mike:filter.pm');
return Apache::DECLINED;
}
my $src = $r->dir_config->get('FilterSource'); my $dst = $r->dir_config->get('FilterDestination');
# unset Content-Length since we're probably changing the length
unless ($f->ctx) {
$r->headers_out->unset('Content-Length');
$f->ctx(1);
}
$log->info('Mike:filter.pm(43): mapping for ', $r->uri, ' (an HTML document)');
while ($f->read(my $buffer, BUFF_LEN)) {
$buffer =~ s/$src/$dst/ig;
$f->print($buffer);
}
$log->info('Exiting Mike:filter.pm'); return Apache::OK; } 1;
2. Used Components and their Configuration: *** mod_perl version 1.9913 *** using d:/Perl/site/lib/Apache2/Apache/BuildConfig.pm *** Makefile.PL options: MP_AP_PREFIX => D:\Apache2 MP_COMPAT_1X => 1 MP_GENERATE_XS => 1 MP_INST_APACHE2 => 1 MP_LIBNAME => mod_perl MP_USE_DSO => 1 MP_USE_STATIC => 1 *** The httpd binary was not found $ ./Apache -V Server version: Apache/2.0.48 Server built: Mar 19 2004 00:05:49 Server's Module Magic Number: 20020903:4 Architecture: 32-bit Server compiled with.... -D APACHE_MPM_DIR="server/mpm/winnt" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D HTTPD_ROOT="/apache" -D SUEXEC_BIN="/apache/bin/suexec" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_ERRORLOG="logs/error.log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf"
$ ./Apache -l
Compiled in modules:
core.c
mod_win32.c
mpm_winnt.c
http_core.c
mod_so.c
*** D:\Perl\bin\perl.exe -V
Summary of my perl5 (revision 5 version 8 subversion 0) configuration:
Platform:
osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread
uname=''
config_args='undef'
hint=recommended, useposix=true, d_sigaction=undef
usethreads=undef use5005threads=undef useithreads=define usemultiplicity=define
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cl', ccflags ='-nologo -Gf -W3 -MD -DNDEBUG -O1 -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUSE_PERLIO -DPERL_MSVCRT_READFIX',
optimize='-MD -DNDEBUG -O1',
cppflags='-DWIN32'
ccversion='', gccversion='', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=10
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='__int64', lseeksize=8
alignbytes=8, prototype=define
Linker and Libraries:
ld='link', ldflags ='-nologo -nodefaultlib -release -libpath:"D:\Perl\lib\CORE" -machine:x86'
libpth="D:\Perl\lib\CORE"
libs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib
perllibs= oldnames.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib winmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib
libc=msvcrt.lib, so=dll, useshrplib=yes, libperl=perl58.lib
gnulibc_version='undef'
Dynamic Linking:
dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' '
cccdlflags=' ', lddlflags='-dll -nologo -nodefaultlib -release -libpath:"D:\Perl\lib\CORE" -machine:x86'
Characteristics of this binary (from libperl):
Compile-time options: MULTIPLICITY USE_ITHREADS USE_LARGE_FILES PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS
Locally applied patches:
ActivePerl Build 804
Built under MSWin32
Compiled at Dec 1 2002 23:15:13
%ENV:
PERL_LWP_USE_HTTP_10="1"
@INC:
D:/Perl/lib
D:/Perl/site/lib
.
3. This is the core dump trace: (if you get a core dump):
[CORE TRACE COMES HERE]
This report was generated by -e on Mon Mar 22 15:21:35 2004 GMT.
--
Thanks a lot,
Michael Franken
-- 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