Posted by : Ino Kun Sabtu, 20 November 2010

teknologi web yang semakin hari semakin berkembang nggak seimbang dengan harga bandwidth yang turun sangat perlahan. Ini tentunya akan membuat kita sebagai administrator pusing 7 keliling di sisi lain harus menghemat belanja bandwidth, di sisi lain pengguna kerap sekali mengakses video streaming yang tentu nya sangat boros bandwidth.
Yang paling susah di akses dengan keterbatasan bandwidth yang ada adalah Video Streaming, yang semakin biasa ada di sekitar kita dengan teknologi flash
dengan format File Flv. Selain youtube banyak juga website lain nya yang menyediakan video streaming diantaranya google video, meta cafe.
Ada sebuah ide menarik dari orang orang yang tergabung di cachevideos.com untuk mencache video video yang sering diakses. mereka menamakan aplikasi dengan nama videocache.

Apa itu Videocache ?
videochache adalah sebuah aplikasi Squid URL rewriter plugin dicoding menggunakan Python untuk optimalisasi bandwidth ketika mengakses website website ( portal ) video sharing terkenal seperti Youtube, Metacafe etc. Aplikasi ini akan membantu anda menghemat bandwidth ketika pengakses video dari network yang sama untuk beberapa video yang sering di request lebih dari sekali.

Apakah caching video nggak cukup dengan squid ?
Squid nggak dapat mengcache video video tersebut secara dinamis. Videocache menyesuaikan kedalam squid untuk membantu mengcache video dengan baik. Video yang di cache di simpan kedalam local disk server anda dan anda dapat mengakses video seperti anda telah mendownloadnya. Anda juga bisa mengcopy video video tersebut ke server lain dengan mudah.

Bagaimana cara kerja videocache ini ?
ketika sebuah video di request dari sebuah website atau portal, videocache menyimpan video yang direquest tersebut kedalam hardisk proxy server. Dan ketika ada request baru video yang sama yang sudah disimpan tersebut si pengakses akan mengakses video tersebut langsung dari proxy server ( seolah olah dari youtube . note : jika akses youtube ). Hal ini akan sangat membantu menghemat bandwidth dan mempercepat loading dari video tersebut.

Dimana kita bisa mendapatkan Aplikasi ini ?
Videocahce merupakan Free Aplikasi untuk berbagai platform dan operating system, dan dapat di download di situs nya yaitu http://cachevideos.com/download

Apa saja yang dibutuhkan untuk membuat Videocache ini ?

Software yang dibutuhkan :
1. FreeBSD 7.0-RELEASE
2. Squid >= 2.6
3. Python >= 2.4
4. Python-urlgrabber
5. Python-iniparse
6. Apache
7. Videocache

Bagai mana cara menginstallasi nya ?

Cara installasi nya relatif mudah karena "Teknologi ada untuk membuat hidup manusia menjadi lebih mudah bukan malah menjadi lebih susah" jadi janganlah hidup

yang mudah ini anda buat jadi susah ( Belajar itu akan membuat hidup manusia lebih mudah , jangan pernah berhenti untuk belajar jika nggak mau susah).
Oke mari kita mulai tahap installasi ini :

1. Anda sudah bisa menginstall FreeBSD 7 Dengan baik dan benar ( bagi yang belum bisa install FreeBSD ada baik nya anda mempelajari nya dahulu sebelum melangkah membuat videocahe ini )

2. Install squid
login ke server anda dengan hak akses root

indofreebsd# cd /usr/ports/www/squid
indofreebsd# make install clean

Konfigurasi squid

indofreebsd# nano /usr/local/etc/squid/squid.conf
----isi squid.conf--------
http_port 3128 transparent
cache_effective_user squid
cache_effective_group squid
acl all src 0.0.0.0/0.0.0.0
icp_query_timeout 1000
high_memory_warning 500 MB
visible_hostname zorro.indofreebsd.or.id
httpd_suppress_version_string on
cache_mem 64 MB
cache_replacement_policy heap GDSF
memory_replacement_policy heap GDSF
cache_swap_low 90
cache_swap_high 95
maximum_object_size 131072 KB
maximum_object_size_in_memory 64 KB
tcp_recv_bufsize 65535 bytes
ipcache_size 8192
fqdncache_size 8192
acl msnmess url_regex http://207.46.111.55/gateway/gateway.dll?
deny_info TCP_RESET msnmess
http_access deny msnmess
forwarded_for off
high_page_fault_warning 10
high_response_time_warning 2000
client_persistent_connections off
server_persistent_connections on
half_closed_clients off
cache_dir aufs /cache 10000 10 256
log_icp_queries off
cache_access_log /usr/local/squid/logs/access.log
emulate_httpd_log on
ftp_user team@indofreebsd.or.idteam@indofreebsd.or.id This e-mail address is being protected from spambots. You need JavaScript enabled to view it
cache_mgr team@indofreebsd.or.idteam@indofreebsd.or.id This e-mail address is being protected from spambots. You need JavaScript enabled to view it
refresh_pattern ^ftp: 1440 20% 10080
refresh_pattern ^gopher: 1440 0% 1440
refresh_pattern . 0 20% 4320
quick_abort_min 0 KB
quick_abort_max 0 KB
negative_dns_ttl 2 minutes
acl mynetwork src 192.168.1.0/26
acl manager proto cache_object
acl localhost src 127.0.0.1/255.255.255.255
acl SSL_ports port 443 563 2082 2083 2086 2087 2093 2095 2096
acl Safe_ports port 80 21 443 563 70 210 8000 11999 2082 2083 2086 2087 2095 2096 8082 8090
acl CONNECT method CONNECT
http_access allow manager localhost
http_access deny manager
http_access deny !Safe_ports
http_access deny CONNECT !SSL_ports
http_access allow mynetwork
http_access allow localhost
deny_info TCP_RESET all
http_access deny all
snmp_port 3001
acl queryme snmp_community SquidSnmpRahasia
acl adminpc src 192.168.1.2
snmp_access allow queryme localhost
snmp_access allow queryme adminpc
snmp_access deny all
icp_access allow mynetwork
icp_access deny all
miss_access allow all
ie_refresh on

----squid.conf-------

save deh dengan nama squid.conf

Selanjutnya buat swap direktori

indofreebsd# squid -z
2009/05/10 16:38:37| Creating Swap Directories

biar jalan setiap kali restart masukan parameter ke /etc/rc.conf
squid_enable="YES"

3. Install Python

indofreebsd# cd /usr/ports/lang/python
indofreebsd# make install clean


4. Install Python-urlgrabber
download dulu source nya di http://linux.duke.edu/projects/urlgrabber/download/urlgrabber-3.1.0.tar.gz atau http://www.indofreebsd.or.id/download/urlgrabber-3.1.0.tar.gz

indofreebsd# fetch http://linux.duke.edu/projects/urlgrabber/download/urlgrabber-3.1.0.tar.gz
indofreebsd# tar -zxvf urlgrabber-3.1.0.tar.gz
indofreebsd# cd urlgrabber-3.1.0
indofreebsd# python setup.py install


5. Install Python-iniparse
download dulu source nya di http://iniparse.googlecode.com/files/iniparse-0.3.1.tar.gz atau di http://www.indofreebsd.or.id/download/iniparse-0.3.1.tar.gz
indofreebsd# fetch http://iniparse.googlecode.com/files/iniparse-0.3.1.tar.gz
indofreebsd# tar -zxvf iniparse-0.3.1.tar.gz
indofreebsd# cd iniparse-0.3.1
indofreebsd# python setup.py install


6. Install Apache
indofreebsd# cd /usr/ports/www/apache22
indofreebsd# make install clean
biar jalan setiap kali restart masukan parameter ke /etc/rc.conf
apache22_enable="YES"


7. Install Videocache
download dulu source nya di http://www.indofreebsd.or.id/download/videocache-1.9.1.tar.gz

indofreebsd# fetch http://www.indofreebsd.or.id/download/videocache-1.9.1.tar.gz
indofreebsd# tar -zxvf videocache-1.9.1.tar.gz
indofreebsd# cd videocache-1.9.1
indofreebsd# python setup.py install
indofreebsd# cp videocache-httpd.conf /usr/local/etc/apache22/videocache.conf
indofreebsd# cp videocache-sysconfig.conf /etc/videocache.conf
indofreebsd# vi /etc/videocache.conf

konfigurasi videocache


#-----isi videocache.conf------
enable_video_cache = 1
cache_host = 192.168.0.1
proxy = http://192.168.0.1:3128/
hit_threshold = 1
base_dir = /usr/local/www/apache22/data/videocache/
disk_avail_threshold = 100
temp_dir = tmp
max_parallel_downloads = 30
enable_videocache_cleaner = 1
video_lifetime = 60
logdir = /usr/local/squid/logs/
max_logfile_size = 10
max_logfile_backups = 10
rpc_host = 127.0.0.1
rpc_port = 9100
enable_youtube_cache = 1
youtube_cache_dir = youtube
max_youtube_video_size = 0
min_youtube_video_size = 0

# Metacafe.com Options
enable_metacafe_cache = 1
metacafe_cache_dir = metacafe
max_metacafe_video_size = 0
min_metacafe_video_size = 0

# Dailymotion.com Options
enable_dailymotion_cache = 1
dailymotion_cache_dir = dailymotion
max_dailymotion_video_size = 0
min_dailymotion_video_size = 0

# Google.com Options
enable_google_cache = 1
google_cache_dir = google
max_google_video_size = 0
min_google_video_size = 0

# Redute.com Options
enable_redtube_cache = 1
redtube_cache_dir = redtube
max_redtube_video_size = 0
min_redtube_video_size = 0

# Xtube.com Options
enable_xtube_cache = 1
xtube_cache_dir = xtube
max_xtube_video_size = 0
min_xtube_video_size = 0

# Vimeo.com Options
enable_vimeo_cache = 1
vimeo_cache_dir = vimeo
max_vimeo_video_size = 0
min_vimeo_video_size = 0

# Wrzuta.pl Options
enable_wrzuta_cache = 1
wrzuta_cache_dir = wrzuta
max_wrzuta_video_size = 0
min_wrzuta_video_size = 0

# Youporn.com Options
enable_youporn_cache = 1
youporn_cache_dir = youporn
max_youporn_video_size = 0
min_youporn_video_size = 0

# Soapbox.msn.com Options
enable_soapbox_cache = 1
soapbox_cache_dir = soapbox
max_soapbox_video_size = 0
min_soapbox_video_size = 0

# Tube8.com Options
enable_tube8_cache = 1
tube8_cache_dir = tube8
max_tube8_video_size = 0
min_tube8_video_size = 0


# Tvuol.uol.com.br Options
enable_tvuol_cache = 1
tvuol_cache_dir = tvuol
max_tvuol_video_size = 0
min_tvuol_video_size = 0

# Blip.tv Options
enable_bliptv_cache = 1
bliptv_cache_dir = bliptv
max_bliptv_video_size = 0
min_bliptv_video_size = 0

# Break.com Options
enable_break_cache = 1
break_cache_dir = break
max_break_video_size = 0
min_break_video_size = 0
#------isi videocache.conf sampe di sini ----#

8. Pengkonfigurasian squid helper pada squid.conf di taro di paling bawah dari squid konfigurasi
indofreebsd# vi /usr/local/etc/squid/squid.conf
#-----------isi squid helper videocache -----#
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 \.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 dl.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 squid


lalu save ...

9. membuat direktori untuk menyimpan video
indofreebsd# cd /usr/local/www/apache22/data
indofreebsd# mkdir videocache/tmp videocache/youtube videocache/metacafe videocache/dailymotion videocache/google videocache/redtube videocache/xtube

videocache/vimeo videocache/wrzuta videocache/youporn videocache/soapbox videocache/tube8 videocache/tvuol videocache/bliptv videocache/break
indofreebsd# chown -R squid:squid videocache


10. Restart Semua service terkait
indofreebsd# /usr/local/etc/rc.d/apache22 restart
indofreebsd# /usr/local/etc/rc.d/squid restart


Jika anda berhasil menginstallnya maka pada log videocache anda akan seperti ini .
indofreebsd# tail -f /usr/local/squid/logs/videocache.log
2009-05-10 19:28:16,032 32243 192.168.0.2 - REQUEST - http://v10.lscache7.googlevideo.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag&itag=34&ip=192.168.0.1&signature=B172DDA7B04663B0F29FBAD60949D5

BAA190CE92.45E154CBB3194D10EF084EA1B63D78A5656080B1&sver=3&expire=1242006370&key=yt1&ipbits=0&id=e8add563176c008f
2009-05-10 19:28:16,033 32243 192.168.0.2 e8add563176c008f URL_HIT YOUTUBE

http://v10.lscache7.googlevideo.com/videoplayback?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag&itag=34&ip=192.168.0.1&signature=B172DDA7B04663B0F29FBAD60949D5

BAA190CE92.45E154CBB3194D10EF084EA1B63D78A5656080B1&sver=3&expire=1242006370&key=yt1&ipbits=0&id=e8add563176c008f
2009-05-10 19:28:16,034 32243 192.168.0.2 e8add563176c008f CACHE_HIT YOUTUBE Video was served from cache.
2009-05-10 19:28:16,035 32243 192.168.0.2 e8add563176c008f NEW_URL YOUTUBE

303:http://192.168.0.1/videocache/youtube/e8add563176c008f?sparams=id%2Cexpire%2Cip%2Cipbits%2Citag&itag=34&ip=192.168.0.1&signature=B172DDA7B04663B0F2 9FBAD60949D5BAA190CE92.45E154CBB3194D10EF084EA1B63D78A5656080B1&sver=3&expire=1242006370&key=yt1&ipbits=0&id=e8add563176c008f


demikan Mengenai videocache semoga bermanfaat.

salam,
ogeb
Referensi :
  • http://cachevideos.com/
  • http://squid-cache.org/
  • http://apache.org

source: http://www.indofreebsd.or.id/proxy-server/optimasi-bandwidth-dengan-freebsd-7-squid-apache-videocache.html

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Lencana Facebook

Follow Me !!!

Popular Post

About Me

Foto Saya
私 の なまえ わ いの ~ くん です~ よろしく~ おねがいしわす~ 

- Copyright © 2013 Anime Is Not Cartoon -Sao v2- Powered by Blogger - Designed by Ino Kun -