[squid-users] Storeurl program,what's wrong with it ?

From: ½ð ¸ê <altman87120_at_gmail.com>
Date: Wed, 5 Dec 2012 20:49:49 +0800

Hi everyone!

I use squid with our ISP services.

And now we use storeurl_rewrite_program for rewrite some video cache for our user. But after a few days draggle and google. We found it's so difficult for us to do this. I can't find where is the error of my configuration.And i hope someone can help.

This is my core thing about the rewrite program.
The squid.conf

acl store_rewrite_list referer_regex ^http://static.youku.com/.*$
storeurl_access allow store_rewrite_list
storeurl_access deny all
storeurl_rewrite_program /var/squid/run/squid/store_url_rewrite.py
------------------------

this is my store_url_rewrite.py
-------------------------
#!/usr/bin/env python
import re
import sys
YOUKU=re.compile("http://\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/youku/.*/(.*-.*-.*-.*-.*)\?.*")

def modify_url(line):
    list = line.split(' ')
    old_url = list[0]
    new_url = '\n'
    is_match = YOUKU.search(old_url)
    if is_match:
            new_url='http://www.youku.com/'+is_match.group(1)+new_url
            return new_url

while True:
    line = sys.stdin.readline().strip()
    new_url = modify_url(line)
    if new_url:
            sys.stdout.write(new_url)
            sys.stderr.write("\n\nREWRITE:"+new_url+'\nORI:'+line)
    else:
            sys.stdout.write(line+'\n')
            sys.stderr.write("NOREWRITE:"+line+'\n')
    sys.stdout.flush()

------------------------------------
throught the stderr , I can find the new_url already write to the log file.But I can't found the it in the store.log

The cache.log

REWRITE:http://www.youku.com/030002050050BCAFBB490B03BAF2B1A20A79FD-0282-DEA6-350C-E810E14BAA19.flv
ORI:http://118.180.3.36/youku/6971A9C8A1E348250177A4314B/030002050050BCAFBB490B03BAF2B1A20A79FD-0282-DEA6-350C-E810E14BAA19.flv?start=17 192.168.108.14/- - GET - myip=192.168.137.20 myport=3128

But there is no
object http://www.youku.com/030002050050BCAFBB490B03BAF2B1A20A79FD-0282-DEA6-350C-E810E14BAA19.flv in store.log

Thanks for your help!

Best wishes!
Received on Wed Dec 05 2012 - 12:49:58 MST

This archive was generated by hypermail 2.2.0 : Thu Dec 06 2012 - 12:00:04 MST