Escolar Documentos
Profissional Documentos
Cultura Documentos
Facebook HTTPS
Google+
Ini catatan pribadi, isinya storeid untuk squid-3.x Support caching youtube (thanks Ces Pun),
Facebook HTTPS, serta beberapa web lainnya (playstore, reverbnation, dan sebagainya). Untuk
mengaktifkan log storeid, silakan set $debug=1; pada storeid, dan buat file /tmp/storeid.log yang
sudah di chown ke user proxy/squid.
Untuk mengecek log, silakan tail -f /tmp/storeid.log.
Note : untuk konfigurasi membutuhkan squid-3.4.7 yang sudah di patch untuk bug # 3937 (storeid
loop).
Konfigurasi
# storeid *test*
refresh_pattern (akamaihd|fbcdn)\.net 14400 99% 518400 ignore-no-store ignoreprivate ignore-reload ignore-must-revalidate store-stale
ignore-no-store ignore-private
Isi storeid.pl
#!/usr/bin/perl
# @ http://www2.fh-lausitz.de/launic/comp/misc/squid/projekt_youtube/
use IO::File;
$|=1;
STDOUT->autoflush(1);
$debug=0;
## recommended:0
$bypassallrules=0;
## recommended:0
$sucks="";
## unused
$sucks="sucks" if ($debug>=1);
$timenow="";
$printtimenow=1;
my $logfile = '/tmp/storeid.log';
$logfh->autoflush(1) if $debug;
while (<>) {
chop;
my $myURL = $_;
@X = split(" ",$myURL);
$a = $X[0]; ## channel id
$b = $X[1]; ## url
$c = $X[2]; ## ip address
$u = $b; ## url
if ($bypassallrules){
} elsif ($u=~
m/http.*\.(fbcdn|akamaihd)\.net\/h(profile|photos).*[\d\w].*\/([\w]\d+x\d+\/.*\.[\d
\w]{3}).*/) {
} elsif ($u=~
m/^http(.*)static(.*)(akamaihd|fbcdn).net\/rsrc.php\/(.*\/.*\/(.*).(js|css|png|gif)
)(\?(.*)|$)/) {
$out="OK store-id=http://google-analytics.squid.internal/__utm.gif";
} elsif ($u=~
m/^https?\:\/\/c2lo\.reverbnation\.com\/audio_player\/ec_stream_song\/(.*)\?.*/) {
} elsif ($u=~
m/^https?\:\/\/.*\.c\.android\.clients\.google\.com\/market\/GetBinary\/GetBinary\/
(.*\/.*)\?.*/) {
@video_id = m/[&?]video_id\=([^\&\s]*)/;
@cpn = m/[&?]cpn\=([^\&\s]*)/;
close FILE;
$out="ERR";
@docid = m/[&?]docid\=([^\&\s]*)/;
@cpn = m/[&?]cpn\=([^\&\s]*)/;
close FILE;
$out="ERR";
@v = m/[&?]v\=([^\&\s]*)/;
@cpn = m/[&?]cpn\=([^\&\s]*)/;
close FILE;
$out="ERR";
@itag = m/[&?](itag\=[0-9]*)/;
@range = m/[&?](range\=[^\&\s]*)/;
@cpn = m/[&?]cpn\=([^\&\s]*)/;
@mime = m/[&?](mime\=[^\&\s]*)/;
@id = m/[&?]id\=([^\&\s]*)/;
if (defined(@cpn[0])){
if (-e "/tmp/@cpn"){
@id = <FILE>;
close FILE;}
$out="OK store-id=http://video-srv.squid.internal/id=@id@mime@range";
} else {
$out="ERR";
Tested untuk cache Facebook HTTPS dan youtube. Silakan di copas kalo pengen :D
Google+
4 Comments