Block Ads with Squid and Easylist

First of all, thanking the members of the blog for this opportunity since I am a fan of DesdeLinux but he had never participated in any topic.

Currently I am an information systems administrator who should save bandwidth as best I can, as well as the safety of clients, since advertising has been linked to many types of tricks and others.

Well, the reason for this post is to show that there are many ways to remove advertising on the Internet. This post inspired me: https://blog.desdelinux.net/privoxy-adblock-list-y-adios-publicidad/, which is great, but I just want to show that there are more ways to do it.

As many will know Squid it is the most popular proxy in all distributions GNU / Linux y Adblock Plus It is the most used extension to eliminate advertising in almost any browser.

I will not elaborate on how to install Squid, since I imagine that many will know, as they will also know that Adblock Plus uses the Easylist lists, which I must say are very extensive.

I must also clarify that this idea is not mine, I came up with this but when I looked for it about 3 years ago there was already information about it, most of it in Russian, English and other languages ​​unknown to me.

To implement it we must create a ACL. In Squid it will be like this:

acl adblock url_regex "/etc/squid3/adblock.acl"
http_access deny adblock

Or if you have any ACL of network range or ips of users to which you want to apply it, you can do it this way:

acl mired src "/etc/squid3/mired.txt"
acl adblock url_regex "/etc/squid3/adblock.acl"
http_access allow mired !adblock

What allows us to serve the ips described in look, denying all who are in the ACL Adblock. Now, with a script we will automate this process, since what we want is to make it easier, more friendly and not so cumbersome, here is the script: http://paste.desdelinux.net/4956.

In source we will add all the Easylist lists that we want or need and the script will take care of the rest. To give you an idea of ​​how it works before using this method:

Screenshot - 040414 - 20:26:22

And after implementing it:

Screenshot - 040414 - 20:27:27

Screenshot - 040414 - 20:27:08

Finally, I would like to add that we will not have to use any extension in the browsers and we can use it throughout our network, considerably saving bandwidth and why not speed up our browsing, without having configuration problems in the clients, since Squid can be configured as a transparent proxy, apart from the many squid utilities for managing a network.


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Eduardo said

    It is very nice without advertising, but "unfortunately" without that advertising many sites would not be working. The best thing, if you like a site, is to pay (if you can) to remove advertising (as is done in softphone applications) or to bank it, lest tomorrow that favorite site disappear because it is not profitable for the one who administers it, Remember that at least a hosting and a domain must be paid, although the purpose is not to profit.

    1.    pandev92 said

      There will always be the uneducated informatics that will render profitable sites, because they don't know about the existence of adblock, that's not a problem.

  2.   fire cold said

    If I understand what you are saying and of course it is fine, at least for you, since as I said to my system administrator I am constantly being asked this kind of thing, both for security and speed and saving bandwidth, the same Everyone is free to do whatever they want, I am not forcing anyone, this is knowledge and the only thing I do is share it, Greetings

  3.   rho said

    Hello! Very good. Can someone tell me if there is a substantial difference with this method and privoxy or directly edit the / etc / hosts?

    I mean, so far banning / etc / hosts is very simple and doesn't require any program or configuration, just adding the hosts. Could someone tell me in what way this method is superior?

    1.    fire cold said

      As I said there are several ways to do it and this is one of many options, of course some are easier than others, the / etc / hosts thing is viable but not at the local network level, Greetings

  4.   Mr. Polyphenol said

    Interesting. Thank you so much for sharing it

    1.    fire cold said

      Thank you very much for your interest, greetings

  5.   Brenner said

    It has served me a lot. Thank you very much for the info. Additionally it would be good to add a grab so that the lists are downloaded periodically although I do not know how often the lists update

  6.   vioscar rivero said

    I want to contribute something, so that the message of "ERROR the requested URL could not be obtained" is not seen, we can make that message be changed. We would only have to place below:

    http_access deny adblock

    following:

    change advertising with html

    deny_info http://192.168.10.2/bloqueo_publicidad.html adblock

    ó

    change of advertising with image

    deny_info http://i.imgur.com/2djunqK.png adblock

    Where with the deny_info parameter, we tell squid to show a custom message in case of not getting the url, and where http://192.168.10.2/bloqueo_publicidad.html it is an .html file with reference to a transparent image with measures of 1 × 1 (or custom page), which will replace the horrible message from squid. It is worth mentioning that with this measure the possibilities are many, from placing our own advertising (using the html method) or completely making advertising invisible (with a transparent image).