I'd like to write a handler that would serve big files out of a local cache but proxy
everything else through to another server. The situation is that there is an extranet in
the US, but a lot of folks in New Zealand need access to the file downloads. I don't
want to replicate the whole installation in NZ, but instead, give them a seperate server
with mod_proxy set up so that when they request most pages it proxies them through from
the main server, but when they ask for a really big file in the /uploads path that it
can pull it out of local cache.
Here's what I have so far:
package CacheHandler;
use Apache2::Request;
use Apache2::Const;
sub handler {
my $r = shift;
if ($r->uri =~ m/^\/uploads/) {
my $path = "/data/cache".$r->uri;
if (-f $path) {
# make it serve up this local file since it exists
}
}
return Apache2::Const::DECLINED;
}
1;
And here's the virtual host I've set up:
<VirtualHost *:80>
ServerName extranet
SSLProxyEngine on
DocumentRoot "/data/cache"
ProxyPass / https://example.com/
PerlModule CacheHandler
PerlInitHandler CacheHandler
</VirtualHost>
What can I add into my handler to make it circumvent the ProxyPass directive? Or if I
can't do that, how can I tell it to enable ProxyPass on any request where I don't pass
those other conditions?
Thanks for any assistance you can provide in advance.
JT ~ Plain Black
ph: 703-286-2525 ext. 810
fax: 312-264-5382
http://www.plainblack.com
I reject your reality, and substitute my own. ~ Adam Savage