/usr/share/perl5/Perlbal/Plugin/AutoRemoveLeadingDir.pm is in libperlbal-perl 1.80-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | package Perlbal::Plugin::AutoRemoveLeadingDir;
#
# this plugin auto-removes a leading directory path component
# in the URL, if it's the name of the directory the webserver
# is rooted at.
#
# if docroot = /home/lj/htdocs/stc/
#
# and user requests:
#
# /stc/img/foo.jpg
#
# Then this plugin will treat that as if it's a request for /img/foo.jpg.
#
# This is useful for css/js/etc to have an "absolute" pathname for
# peer resources (think css having url(/stc/foo.jpg)) that can be served
# from either a separate hostname (stat.livejournal.com) and using a CDN,
# or from www. when cross-domain js restrictions require it.
use Perlbal;
use strict;
use warnings;
sub load { 1 }
sub unload { 1 }
# called when we're being added to a service
sub register {
my ($class, $svc) = @_;
$svc->register_hook('AutoRemoveLeadingDir', 'start_serve_request', sub {
my Perlbal::ClientHTTPBase $client = shift;
my $uriref = shift;
my Perlbal::Service $svc = $client->{service};
my ($tail) = ($svc->{docroot} =~ m!/([\w-]+)/?$!);
$$uriref =~ s!^/$tail!! if $tail;
return 0;
});
return 1;
}
# called when we're no longer active on a service
sub unregister {
my ($class, $svc) = @_;
return 1;
}
1;
|