Apache2-BalanceLogic

 view release on metacpan or  search on metacpan

lib/Apache2/BalanceLogic.pm  view on Meta::CPAN


    # run!
    my $route_id = $plugin->run($r);
    return Apache2::Const::DECLINED unless $route_id;

    # you can forward a request for a server apointed in '__force__' query string.
    my $args = $r->args;
    if ( $args =~ /__force__=(\d+)$/ ) {
        my $force    = $1;
        my $ip       = $r->connection->remote_ip;
        my $cidr     = Net::CIDR::Lite->new;
        my $admin_ip = $conf->{ADMIN_IP} or die($!);
        for (@$admin_ip) {
            $cidr->add_any($_);
        }
        $route_id = $force if $cidr->find($ip);
    }

    # a inner cookie trick for "stickysession" in mod_proxy_balancer.
    my $cookie_str = $r->headers_in->get('Cookie');
    $cookie_str =~ s/route_id=\d+\;?//;
    $cookie_str = 'route_id=x.' . $route_id . '; ' . $cookie_str . ';';
    $r->headers_in->set( 'Cookie' => $cookie_str );

    # return OK
    return Apache2::Const::OK;



( run in 0.292 second using v1.01-cache-2.11-cpan-de7293f3b23 )