RHEL / CentOS: Youtube Video Cache With Squid and Nginx
On this occasion, we will discuss the process of installing Youtube Video Cache with Squid and Nginx on RHEL / CentOS where in previous writings more often used Ubuntu server in terms of creating a proxy server, but this time we will use OS Linux RHEL / CentOS 6 where to further explore our knowledge (I am personally) in terms of Linux networking: D. However, if you are still using the proxy world (ubuntu server), maybe this is one alternative in making proxy servers on RPM-based machines.
Install the packages needed in the squid installation process:
# yum install patch gcc make ccze ruby
# cd /root
# wget -c http://www.squid-cache.org/Versions/v2/2.7/squid-2.7.STABLE9.tar.gz
# tar -xvzf squid-2.7.STABLE9.tar.gz
# cd squid-2.7.STABLE9/src/
# wget http://youtube-cache.googlecode.com/files/patch-youtube
# patch -p0 client_side.c < patch-youtube
# cd ../
Configure Squid with the following parameters:
./configure --prefix=/usr --exec_prefix=/usr --bindir=/usr/sbin --sbindir=/usr/sbin
--libexecdir=/usr/lib/squid --sysconfdir=/etc/squid
--localstatedir=/var/spool/squid --datadir=/usr/share/squid
--enable-async-io=24 --with-aufs-threads=24 --with-pthreads
--enable-storeio=aufs --enable-linux-netfilter --enable-arp-acl
--enable-epoll --enable-removal-policies=heap --with-aio
--with-dl --enable-snmp --enable-delay-pools --enable-htcp
--enable-cache-digests --disable-unlinkd --enable-large-cache-files
--with-large-files --enable-err-languages=English
--enable-default-err-language=English --with-maxfd=65536
Add and unlock Squid user password:
# useradd squid
# passwd -fu squid
Add the epel repository to install nginx:
# cd /root
# wget -c http://mirror.smartmedia.net.id/epel/6Server/x86_64/
epel-release-6-8.noarch.rpm
# rpm -ivh epel-release-6-8.noarch.rpm
The installation and backup process for squid.conf and nginx.conf configurations:
# yum install nginx
# mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.backup
# mv /etc/squid/squid.conf /etc/squid/squid.conf.backup
Download examples of squid.conf and nginx.conf configurations from techsoftcenter google code:
# cd /etc
# wget -c http://techsoftcenter .googlecode.com/files/techsoftcenter
-squid%2Bnginx-video-cache.tar.gz
# tar -xvzf techsoftcenter -squid+nginx-video-cache.tar.gz
Set ownership of folder/cache access, build squid folder, disable iptables and set so that Squid can run when the system is turned on:
# chown squid.squid /cache
# squid -z
# iptables -F && service iptables save
# vi /etc/rc.d/rc.local
add the following configuration rc.local:
/usr/sbin/squid -NDd1 &
Disable SELinux:
# vi /etc/selinux/config
set disable selinux
SELINUX=disabled
Run the nginx service and set the folder parameters that nginx has:
Restart your proxy machine
# chkconfig nginx on
# mkdir -p /cache/nginx_cache/files
# mkdir /cache/nginx_cache/tmp
# chown -Rf nginx.nginx /cache/nginx_cache
# mkdir /var/log/squid
# chown -Rf squid.squid /var/log/squid
# reboot -fn
# tail -f /var/log/squid/access.log | ccze
# tail -f /var/log/nginx/access.log | ccze
