[squid-users] Reverse Proxy Redirector Help

From: Joe Tiedeman <Joe.Tiedeman@dont-contact.us>
Date: Tue, 19 Feb 2008 12:59:08 -0000

Hi All,

I'm using Squid 2.6 Stable 18 on RHEL4 in a reverse proxy configuration
and haven't been able to find any redirectors out there which do exactly
what I would like, so I'm in the process of writing my own very simple
one in php (code below - it's by NO means complete, I'm still in the
really early development stages)

It seems to be working fine so far, just outputting to my logfile
everything which squid passes to it, however every minute (to the
second) each of the spawned redirectors puts this into the cache.log and
I can't for the life of me figure out why!

helperHandleRead: unexpected read from url_rewriter #2, 1 bytes '

It also seems that every now and again squid sends a black request to
the redirectors as they put blank lines into the temporary logfile.

It could be that I'm doing something very stupid (highly likely!) but I
was wondering if anyone could help.

Many Thanks in advance!

Joe

<?php

$stdin = fopen('php://stdin', 'r');

while (1) {

#$stdin = fopen('php://stdin', 'r');

        $line = trim(fgets($stdin));
        $filename = '/tmp/phpredirector.log';
        $somecontent = $line."\n";

// Let's make sure the file exists and is writable first.
if (is_writable($filename)) {

    // In our example we're opening $filename in append mode.
    // The file pointer is at the bottom of the file hence
    // that's where $somecontent will go when we fwrite() it.
    if (!$handle = fopen($filename, 'a')) {
         echo "couldn't open the file";
    }

    // Write $somecontent to our opened file.
    if (fwrite($handle, $somecontent) === FALSE) {
        echo "couldn't write to the file";
    }

    fclose($handle);
    echo PHP_EOL;

} else {
    exit;
}
}

?>

_____________________________________________________________________

Higher Education Statistics Agency Ltd (HESA) is a company limited by
guarantee, registered in England at 95 Promenade Cheltenham GL50 1HZ.
Registered No. 2766993. The members are Universities UK and GuildHE.
Registered Charity No. 1039709. Certified to ISO 9001 and BS 7799.
 
HESA Services Ltd (HSL) is a wholly owned subsidiary of HESA,
registered in England at the same address. Registered No. 3109219.
_____________________________________________________________________

This outgoing email was virus scanned for HESA by MessageLabs.
_____________________________________________________________________
Received on Tue Feb 19 2008 - 05:59:12 MST

This archive was generated by hypermail pre-2.1.9 : Sat Mar 01 2008 - 12:00:05 MST