Brad Fitzpatrick (brad) wrote,
Brad Fitzpatrick
brad

Apache configuration challenge/question

Dear Lazyweb,

Anybody know Apache well enough to help with this? I'll have to skip the background and rationale for now, but basically I need:

#1: Some backend HTTP server serving static files:
-- Apache 1.3, whatever.
-- notable, these include HTML files including SSI <--#include virtual="..." --> tags w/ relative paths
-- but this server doesn't do SSI expansion
-- don't need help with this part.

#2: Apache 2.x front-end that does:
-- mod_rewrite external "prg:" program map to map path to full URL of server #1, above
-- result of that prg: map goes to [P] (to mod_proxy)
-- SSI expansion of the result, using, say, "SetOutputFilter INCLUDES"
-- those virtual includes then need to start back over at mod_rewrite/map/proxy/SSI.

So far I have two solution, neither of which totally work. The basic one which got me hopeful was:

ProxyPass / http://127.0.0.1:81/
ProxyPassReverse / http://127.0.0.1:81/
<Proxy http://127.0.0.1:81/*>
Order deny,allow
Allow from all
SetOutputFilter INCLUDES
</Proxy>

That properly does the SSI expansion, and fetches the virtual includes as well from the remote proxy server.

So I thought: Just add the rewrite map!

So I removed the ProxyPass/ProxyPassReverse lines and added:

RewriteEngine on
RewriteMap extmap prg:/var/www/extmap.pl
RewriteRule ^(.*) ${extmap:$1} [P]

Where extmap.pl is:

#!/usr/bin/perl
$| = 1;
while (my $in = <STDIN>) {
    chomp $in;
    $in .= "l" if $in =~ /\.htm$/;
    print "http://127.0.0.1:81$in\n";
}


But that only half-works. If I then hit /index.htm, mod_rewrite changes it to http://127.0.0.1:81/index.html and expands the static SSI tags (like inserting current date, etc) but the #include tags aren't sent back through mod_rewrite, or at least not the map.... (yes, I have RewriteLogLevel 5). Instead, Apache is looking for the included files locally, in /var/www (the base directory which is actually empty, except for my map function).

So basically I can get proxying working (with virtual includes), or external map working, but not both.

I've tried various combinations of [P,PT], [P,N], etc (the mod_rewrite flags for control flow) but I'm running out of ideas.

Any winners get the only prizes I can give out easily: LJ paid/perm accounts. :-) (although this isn't for LJ at all.....)

Thanks!
Tags: apache, lazyweb, tech
Subscribe
  • Post a new comment

    Error

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

    When you submit the form an invisible reCAPTCHA check will be performed.
    You must follow the Privacy Policy and Google Terms of use.
  • 15 comments