Wednesday, 23 December 2009 10:40

Caching video dengan Squid

Written by Administrator
Rate this item
(0 votes)

Setelah beberapa hari monitoring traffic, ternyata banyak traffic yang lari ke youtube dkk. Berhubung tidak ada larangan untuk mengakses situs situs semacam youtube dkk, maka untuk itu saya mencoba untuk menginstall Caching video dengan Squid. Pada tutorial kali ini saya tekankan bahawa squid sudah berjalan dengan baik. Ok... langsung saja, begini langkahnya :

  • Install Python >= versi 2.4 keatas
  • Python-urlgrabber (modul urlgrabber untuk python)
  • Python-iniparse (modul iniparse untuk python)
  • Web Server (Apache2 atau Lighttpd)

Untuk menginstall Python-urlgrabber (modul urlgrabber untuk python), berikut langkahnya :

download Python-urlgrabber

sudo wget -c http://archive.ubuntu.com/ubuntu/pool/main/u/urlgrabber/urlgrabber_3.1.0.orig.tar.gz

ekstrak paket

tar -zxvf urlgrabber-3.1.0.tar.gz

masuk direktori dan compile

sudo python setup.py install

Untuk menginstall Python-inipars (modul urlgrabber untuk python), berikut langkahnya :

download Python-inipars

sudo wget -c http://iniparse.googlecode.com/files/iniparse-0.3.1.tar.gz

ekstrak paket

tar -zxvf iniparse-0.3.1.tar.gz

masuk direktori dan compile

sudo python setup.py install

Konfigurasi videocache dengan Squid

download videocache

sudo wget -c http://cachevideos.com/sites/default/files/pub/videocache/videocache-1.9.1.tar.gz

ekstrak paket

tar -zxvf videocache-1.9.1.tar.gz

masuk direktori dan edit file setup.py

sudo nano setup.py
-------------------------------
squid_user = 'proxy'
squid_group = 'proxy'
apache_conf_dir = '/etc/apache2/conf.d/'
-------------------------------

kemudian compile

sudo python setup.py install

setelah itu tambahkan script dibawah ini pada baris akhir konfigurasi Squid anda


# --BEGIN-- videocache config for squid
url_rewrite_program /usr/bin/python /usr/share/videocache/videocache.py
url_rewrite_children 7
acl videocache_allow_url url_regex -i \.youtube\.com\/get_video\?
acl videocache_allow_url url_regex -i \.youtube\.com\/videoplayback \.youtube\.com\/videoplay \.youtube\.com\/get_video\?
acl videocache_allow_url url_regex -i \.youtube\.[a-z][a-z]\/videoplayback \.youtube\.[a-z][a-z]\/videoplay \.youtube\.[a-z][a-z]\/get_video\?
acl videocache_allow_url url_regex -i \.googlevideo\.com\/videoplayback \.googlevideo\.com\/videoplay \.googlevideo\.com\/get_video\?
acl videocache_allow_url url_regex -i \.google\.com\/videoplayback \.google\.com\/videoplay \.google\.com\/get_video\?
acl videocache_allow_url url_regex -i \.google\.[a-z][a-z]\/videoplayback \.google\.[a-z][a-z]\/videoplay \.google\.[a-z][a-z]\/get_video\?
acl videocache_allow_url url_regex -i (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/videoplayback\?
acl videocache_allow_url url_regex -i (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/videoplay\?
acl videocache_allow_url url_regex -i (25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\/get_video\?
acl videocache_allow_url url_regex -i proxy[a-z0-9\-][a-z0-9][a-z0-9][a-z0-9]?\.dailymotion\.com\/
acl videocache_allow_url url_regex -i vid\.akm\.dailymotion\.com\/
acl videocache_allow_url url_regex -i [a-z0-9][0-9a-z][0-9a-z]?[0-9a-z]?[0-9a-z]?\.xtube\.com\/(.*)flv
acl videocache_allow_url url_regex -i bitcast\.vimeo\.com\/vimeo\/videos\/
acl videocache_allow_url url_regex -i va\.wrzuta\.pl\/wa[0-9][0-9][0-9][0-9]?
acl videocache_allow_url url_regex -i \.files\.youporn\.com\/(.*)\/flv\/
acl videocache_allow_url url_regex -i \.msn\.com\.edgesuite\.net\/(.*)\.flv
acl videocache_allow_url url_regex -i media[a-z0-9]?[a-z0-9]?[a-z0-9]?\.tube8\.com\/ mobile[a-z0-9]?[a-z0-9]?[a-z0-9]?\.tube8\.com\/
acl videocache_allow_url url_regex -i \.mais\.uol\.com\.br\/(.*)\.flv
acl videocache_allow_url url_regex -i \.video[a-z0-9]?[a-z0-9]?\.blip\.tv\/(.*)\.(flv|avi|mov|mp3|m4v|mp4|wmv|rm|ram)
acl videocache_allow_url url_regex -i video\.break\.com\/(.*)\.(flv|mp4)
acl videocache_allow_dom dstdomain .mccont.com .metacafe.com .redtube.com .cdn.dailymotion.com
acl videocache_deny_url url_regex -i http:\/\/[a-z][a-z]\.youtube\.com http:\/\/www\.youtube\.com
url_rewrite_access deny videocache_deny_url
url_rewrite_access allow videocache_allow_url
url_rewrite_access allow videocache_allow_dom
redirector_bypass on
# --END-- videocache config for squid

edit juga file konfigurasi dari videocache dan ganti parameter berikut


sudo nano /etc/videocache.conf
-------------------------------
cache_host = ip-squid
proxy = http://ip-squid:3128/

-------------------------------

kemudian restart squid dan apache, untuk melihat log videocache

tail -f /var/log/videocache/videocache.log

Last modified on Monday, 28 December 2009 12:30
Administrator

Administrator

E-mail: This e-mail address is being protected from spambots. You need JavaScript enabled to view it

1 comment

  • Comment Link novferdianto Thursday, 01 April 2010 12:43 posted by novferdianto

    Good.. it works !

    This e-mail address is being protected from spambots. You need JavaScript enabled to view it

Add comment


#fc3424 #5835a1 #1975f2 #b487c5 #af8cb4 #3ac3c6