How to block Youtube videos using Squid proxy Server on Ubuntu
YouTube is number one headache for companies and for networks administrators. It distracts the employees from their daily tasks with negative influence on company productivity and also take a big amount of internet bandwidth so working with mass amount Ethernet data is sluggish and non productive. So, how can you block YouTube videos?
We will use Squid proxy server. Squid server is a popular open source GPLd proxy and web cache. It has a variety of uses, from speeding up a web server by caching repeated requests, to caching web, name server queries, and other network lookups for a group of people sharing network resources. Squid is a high-performance proxy caching server for Web clients, supporting FTP, gopher, and HTTP data objects. Unlike traditional caching software, Squid handles all requests in a single, non-blocking, I/O-driven process. Squid keeps meta data and especially hot objects cached in RAM, caches DNS lookups, supports non-blocking DNS lookups, and implements negative caching of failed requests. Squid consists of a main server program squid, a Domain Name System lookup program (dnsserver), a program for retrieving FTP data (ftpget), and some management and client tools.
To install and configure squid on Ubuntu check this link.
To set Squid to work without problems on all Ubuntu versions, change the default listening TCP port 3128 to TCP port 8888.
After installation you can continue with restricting YouTube videos.the MIME type of YouTube video is “video/x-flv”. To block this mime type, you must modify squid configuration file /etc/squid/squid.conf and add the next lines in the ACL section.
1. Create an ACL which matches the MIME type in question:
acl deny_rep_mime_flashvideo rep_mime_type video/x-flv
2. Then create a HTTP Reply ACL which denies any replies with that MIME type:
http_reply_access deny deny_rep_mime_flashvideo
3. After that restart squid.
sudo /etc/init.d/squid restart
The new settings will be loaded and now the YouTube content should be blocked. Try to play YouTube video. If the content is blocked the following similar line will be seen in access.log:
2282485683.146 903 127.0.0.1 TCP_DENIED_REPLY/403 3143 GET http://td.v17.cache4.c.youtube.com/videoplayback? – DIRECT/192.118.152.148 text/html
We hope that this will increase your company productivity and will eliminate distractions and empty hours spent on watching YouTube videos.
Tags | Howto, Linux, Tips and Tricks, Ubuntu, youtube
Thanks,
For months i was keep figuring out why my configuration failed. When you did mentioned about x-flv, it’s awake mee. I am being using just flv, which made my rules by-passable.
It worked. Now how about disabling streaming music?