Squid proxy server- Installation & Configuration (Part 2)

Welcome back Linux-fanatics. In our part 1 of the tutorial, we discussed installation & configuration of Squid proxy server, configuration on client’s machine & blocking a single website.

Now, we will proceed further & discuss how to block multiple website with single acl, creating a time based acl & also speeding up our browsing by enabling cache.

( Also Read : Setting up SQUID AUTHENTICATION )

Blocking Multiple websites

Firstly, we will create a file named blacksites (or bad-domains or whatever )

vi /etc/squid/blacksites

and add the websites we need blocked & save the file


Now, open main configuration file

vi /etc/squid/squid.conf

and create a new acl

acl blacksites dstdomain /etc/squid/blacksites

then, we deny access to the created acl

http_access deny blacksites

lastly, restart proxy server to apply changes.

service squid restart

Note you can also use squid -k reconfigure to apply changes to server without actually restarting the server.

Time based acl

Sometimes, we might require access to a blocked website for a certain period of time or we might need to block certain websites for certain time. This can be achieved using a time based acl

Firstly, open configuration file

vi /etc/squid/squid.conf

then create a new acl and allow access to the acl

acl timebased time MTW 10:30-11:30
http_access allow blacksites

lastly, restart your server to implement changes. & we now have access of blocked sites on Monday, Tuesday & Wednesday between 10:30AM to 11:30AM .

Enabling cache to speed up browsing

So, by enabling cache in our server we can speed up our browsing speed for frequently visited pages.

By adding just one line in our configuration file, we can enable cache.

To enable cache , open configuration file

vi /etc/squid/squid.conf

and add following line to bottom of the file

cache_dir ufs /var/cache/squid 2000 16 256

where ufs is squid storage format,

/var/cache/squid is path for cache storage,

2000 is size in MB can be used for cache,

and, 16 is number of 1st level sub-directories & 256 is 2nd level sub directories in cache folder.


So this concludes our tutorial, hope it simple enough to follow. In next tutorial we will discuss SARG , which analyze all the proxy logs & present them in nice, easy to understand HTML format.

and If having any doubts/queries or suggestions, leave it in comments section below & I will get back to you.ADIOS !!!

If you think we have helped you or just want to support us, please consider these :-

Connect to us: Facebook | Twitter | Google Plus

Become a Supporter – Donate us some of you hard earned money:

Linux TechLab is thankful for your continued support.


Passionate about Linux & open source. Loves to learn, read & write about Linux as well as new technologies.

You may also like...

2 Responses

  1. Thanks for your tutorial. Very nicely written and very informative.

    Maybe a stupid question but where do you put the cache server? I just want to start caching content without anybody having to set their proxy so, as a test, I created a physical Ubuntu squid server. I get the configuration part but where do I plug it in so that it’s able to cache the internet traffic and serve up whatever content it can?

    And how big do I make the cache? The conf file shows 100MB while your example shows 2000MB but I’m thinking it should be much much bigger.

    And I read that I could have problems if I try to cache files larger than 4MB but if I want to cache things like YouTube videos, wouldn’t I need a larger max file size?

    Thanks in advance.

    • Shusain says:

      Hi Clayton,

      There are no stupid questions, especially when it comes to Linux. Now to answer your questions, you can put cache anywhere on your filesystem. You just need to mention the directive ‘cache_dir’ in squid configuration file. You can specify multiple cache_dir lines to spread the cache among different disk partitions.
      As for size, The default is 100 MB. Change this to suit your configuration. Do NOT put the size of your disk drive here. Instead, if you want Squid to use the entire disk drive, subtract 20% and use that value.
      For problem with caching objects larger than 4MB, i have not experienced something like that myself. But you might be getting this as you might not have mentioned ‘maximum_object_size’ directive. Set ‘maximum_object_size 128 MB’ to cache object 128 MB objects or something of your choosing & make sure that its written before ‘cache_dir’ directive on squid config file.
      I hope that i have addressed all your queries to your satisfaction.

Leave a Reply

Your email address will not be published. Required fields are marked *