Tuesday, November 18, 2008

Dyndns not forwarding

This is odd is seems dyndns has stopped forwarding sitegeisha.dyndns.dk to my server, however I tried using SSH using sitegeisha.dyndns.dk and it work, also tried ftp and it worked, tried accessing using other ports and it also worked.

I also checked to see if port 80 was accessible from the outside and it was okay. http://www.canyouseeme.org/

WTF is going on???!!!

Tuesday, November 11, 2008

Youtube Cache with Squid + Lighttpd on Ubuntu

Download the source code from http://cachevideos.com/download

I used this one.
wget http://cachevideos.com/sites/default/files/pub/youtube_cache/youtube_cache-1.2.tar.gz
Make sure you got all the requirements.

1. Squid >= 2.6
2. Python >= 2.4
3. Python-urlgrabber (urlgrabber module of python)
4. Python-iniparse (iniparse module of python)
5. Lighttpd Web Server

For the iniparse there is nothing on the repositories you can download it here: http://code.google.com/p/iniparse/

After downloading extract it, on the terminal type:

sudo python setup.py install

Extract the youtube_cache-1.2.tar.gz archive if you haven't done so already.

Open the setup.py file from youtube cache and make this changes to the following entries

squid_user = 'proxy'
squid_group = 'proxy'

Create a dummy folder apache just don't want to get any errors with the install
apache_conf_dir = '/etc/apache2/conf.d/'

save it and type:

sudo python setup.py install
edit your squid conf file

sudo gedit /etc/squid/squid.conf

Paste the following at the end of the file:

url_rewrite_program /usr/bin/python /etc/squid/youtube_cache/youtube_cache.py
url_rewrite_children 10
acl youtube_query url_regex -i \.youtube\.com\/get_video
acl youtube_query url_regex -i \.cache[a-z0-9]?[a-z0-9]?[a-z0-9]?\.googlevideo\.com\/videoplayback
acl youtube_query url_regex -i \.cache[a-z0-9]?[a-z0-9]?[a-z0-9]?\.googlevideo\.com\/get_video
acl youtube_deny url_regex -i http:\/\/[a-z][a-z]\.youtube\.com
acl metacafe_query dstdomain v.mccont.com
acl dailymotion_query url_regex -i proxy\-[0-9][0-9]\.dailymotion\.com\/
acl google_query dstdomain vp.video.google.com
acl redtube_query dstdomain dl.redtube.com
acl xtube_query url_regex -i [a-z0-9][0-9a-z][0-9a-z]?[0-9a-z]?[0-9a-z]?\.xtube\.com\/(.*)flv
acl vimeo_query url_regex -i bitcast\.vimeo\.com\/vimeo\/videos\/
acl wrzuta_query url_regex -i va\.wrzuta\.pl\/wa[0-9][0-9][0-9][0-9]?
url_rewrite_access deny youtube_deny
url_rewrite_access allow youtube_query
url_rewrite_access allow metacafe_query
url_rewrite_access allow dailymotion_query
url_rewrite_access allow google_query
url_rewrite_access allow redtube_query
url_rewrite_access allow xtube_query
url_rewrite_access allow vimeo_query
url_rewrite_access allow wrzuta_query
redirector_bypass on

edit /etc/youtube_cache.conf

change the base_dir to /var/www/video_cache

IMPORTANT: change cache_host = IPADDRESS of the PROXY

cache_host =

sudo cp -r /var/spool/squid/video_cache /var/www/

make sure you can access this folder from http://localhost/video_cache
otherwise the cached flv files won't get served.

restart your squid and apache

sudo /etc/init.d/squid restart
sudo /etc/init.d/lighttpd restart

Configure the browsers to use your proxy and you can check if its working by typing

sudo tail -f /var/log/squid/youtube_cache.log
If it is working correctly after watching a video and trying to watch it again you should see something like this on the log file.

DOWNLOAD YOUTUBE 10167389 Video was downloaded and cached.
CACHE_SERVE YOUTUBE Video was served from cache.

Hope you get it to work too, those damn kids and their videos bahhh!!!