Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Phred (5358)


Fred is a Perl and PostgreSQL geek. He has made some very small contributions to a few cpan modules and mod_perl.

Journal of Phred (5358)

Friday May 12, 2006
10:50 PM

Tuit reclamation

[ #29603 ]

There are times in life when you find yourself with tuits. Use them while you can, because often what follows is a period when you are without them. I like to hack Perl, and do so as much as I can, but sometimes bills, family, friends' websites, and other nuances get in the way. Work gets in the way too, but I get to hack Perl at work, albeit it doesn't always have the freedom and rewards of working on open source software.

So I had some tuits about a month ago, I started hacking, and then my tuits got re-alloc'd. Tonight I can finally reclaim them, as my free music trading site is finally back online. It runs Slash, and uses Perlbal to deliver http content to hungry clients. I configured Perlbal to proxy requests to the Slash server, and if the request was for a music file, mod_perl passed the request back to Perlbal with a 'x-reproxy-file' header, and Perlbal served the file asynchronously. Today the server was pushing over 40 megabits per second and Perlbal was using about 8% cpu on a PIII 1Ghz Coppermine. Whew.

Time to get to work with the reclaimed tuits on open source. And I'll start with the handler code I used to do this. This works with Perlbal 1.41 and Slash 2.2.6.

package Music;

use Apache::Constants qw( :common );

sub handler {
    my $r    = shift;
    my $file = $r->document_root . $r->uri();
    return DECLINED if -d $file;
    if (-e $file) {
        $r->log_error("Setting X-REPROXY for $file");

        $r->err_header_out('X-REPROXY-FILE' => $file);
                return OK;
    if ( ! -e $file ) { return NOT_FOUND };


  SET listen =
  SET role = reverse_proxy
  SET pool = my_apaches
  SET enable_reproxy = true
  SET persist_client=off
  SET persist_backend=off
  SET verify_backend = on
ENABLE balancer

# always good to keep an internal management port open:
  SET role   = management
  SET listen =

<FilesMatch "\.(flac|vob|VOB|shn|txt|md5)$">
SetHandler perl-script
  PerlHandler Music
<Directory /usr/local/slash/site/>
Options Includes Indexes Multiviews FollowSymLinks
        AllowOverride All
        IndexOptions FancyIndexing SuppressHTMLPreamble DescriptionWidth=*
HeaderName /HEADER.html

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.