Personal tools

Setup VideoCache with Squid

From PFSenseDocs

Jump to: navigation, search
This article is part of the HOWTO series.

Contents

Summary

This howto covers the process of installing videocache on pfSense. This howto assumes that you already have squid installed, configured, and working.

Important30.png WARNING Important30.png
This is unsupported, use at your own risk

Install Python

Install python and additional libraries, using either the console or ssh.

# pkg_add -r python
# pkg_add -r py25-bsddb
# pkg_add -r py25-gdbm
# pkg_add -r py25-sqlite3
# pkg_add -r py25-tkinter

Install URLGrabber

Download the latest version from the URLGrabber Download Archive. Replace x.x.x with the version you are installing.

# fetch http:/linux.duke.edu/projects/urlgrabber/download/urlgrabber-x.x.x.tar.gz
# tar -xzf urlgrabber-x.x.x.tar.gz
# cd urlgrabber-x.x.x
# python setup.py bdist_rpm
# python setup.py install

Install Iniparse

Download the latest version of python-iniparse from Iniparse Project Website. Replace x.x.x with the version you are installing.

# fetch http:/iniparse.googlecode.com/files/iniparse-x.x.x.tar.gz
# tar -xzf iniparse-x.x.x.tar.gz
# cd iniparse-x.x.x
# python setup.py bdist_rpm
# python setup.py install

Install VideoCache

# fetch http:/cachevideos.com/sites/default/files/pub/videocache/videocache-x.x.tar.gz
# tar -xvzf videocache-x.x.tar.gz
# python setup.py install

Configure VideoCache

Edit the /etc/videocache.conf file and change the following options in the file.

  • proxy
Set the IP address and port on which squid is listening on PFsense.
  • cache_host
The IP address of PFsense.

Configure Squid

Add the following lines to /usr/local/pkg/squid.inc after acl.

# --BEGIN-- videocache config for squid
url_rewrite_program /usr/bin/python /usr/share/videocache/videocache.py
url_rewrite_children 10
acl videocache_allow_url url_regex -i \.youtube\.com\/get_video
acl videocache_allow_url url_regex -i \.cache[a-z0-9]?[a-z0-9]?[a-z0-9]?\.googlevideo\.com\/videoplayback
acl videocache_allow_url url_regex -i \.cache[a-z0-9]?[a-z0-9]?[a-z0-9]?\.googlevideo\.com\/get_video
acl videocache_allow_url url_regex -i proxy\-[0-9][0-9]\.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_dom dstdomain v.mccont.com vp.video.google.com dl.redtube.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

Save and restart squid service and you have videocache running on your PFsense.

You may also need to disable the https option in the General Setup Settings.

Courtesy of Mohd Izhar Ali, with some minor changes.

If you have issues, you may also want to take a look at: http://www.bellera.cat/josep/videocache/