Privoxy + AdBlock List and goodbye advertising.

The topic of Internet advertising is a somewhat tricky business, and the reasons for this are quite obvious, since many websites are active thanks to the advertising that is on them, and that is a perfectly understandable situation.

The but is, that many times advertising is somewhat annoying, with ads in bright colors and flashing banners that are simply unbearable and intrusive, not to mention that much of this advertising is a danger because it lends itself as a gateway to Adware, URL hijacking, among other types of malware and practices that can compromise our security while browsing the Internet.

That is why the following tutorial is aimed at controlling this, but without using the tools that we would normally access, such as the one recognized AdBlock Plus o ad block edge, but rather a simple program that can do that and much more as we configure it and that the pro has, in which its configuration can be set globally for the entire system, thus covering any browser that we use, well be Gnome Web, IceCat, Iceweasel, Midori, Opera, among others.

I'm talking about privoxy, which we will use together with a small and simple bash script to use the Adblock Plus lists without major problem. Knowing this, there is nothing left but to get to work 🙂

What is Privoxy?

Privoxy, is a no-cache proxy With content filtering options made with privacy in mind, it is not recommended for use on networks. TOR e I2P together with Polipo. privoxy It also allows us to get rid of annoying advertising and other garbage that we can get on the Internet, all with a simple configuration.

This software is licensed under GPLv2, and our friend @usemoslinux had told us a bit about this tool in a previous occasion, and in this case, I will only expand said information in order to make it more effective against a greater range of advertising, which evolves day after day like everything else on the Internet.

The steps described in this tutorial are done on a Debian GNU / Linux OS, however, this information can be useful under any other GNU / Linux OS by adjusting the installation commands, and editing the files described here.

How to install and configure Privoxy + Adblock List?

First we open a terminal, and type the following:

sudo apt-get update && sudo apt-get install privoxy

This will allow us to install privoxy with its default configuration, which we will have to adjust a bit in order to use it effectively. Our second step addresses precisely that, and is to edit the configuration file located at / etc / privoxy / config. To do this we go to the terminal and type the following command:

sudo nano /etc/privoxy/config

Once the file is open we will look for the following string:

#listen-address 127.0.0.1:8118

We uncomment it, remaining as follows:

listen-address 127.0.0.1:8118

This tells privoxy it listens for connections from 127.0.0.1, that is, local connections from our PC.

Having made this point, we now continue with the most important part of all this, which is to add support to privoxy to handle the lists of Adblock Plus, and we do that thanks to a simple bash script created by Andrew, which can be installed in the following way:

We go back to the terminal and type:

cd /etc/privoxy

At this point we download the script, which is publicly available at GitHub, for this we use wget with the following command:

sudo wget https://raw.github.com/Andrwe/privoxy-blocklist/master/privoxy-blocklist.sh --no-check-certificate

Once the script has been downloaded, we proceed to give it execution permission:

sudo chmod +x privoxy-blocklist.sh

We make a thirst on the file privoxy-blocklist.sh in order to adjust the configuration file of the aforementioned script:

sudo sed -i s/^SCRIPTCONF.*/SCRIPTCONF=\\/etc\\/privoxy\\/blocklist.conf/ privoxy-blocklist.sh

To then create the configuration file /etc/privoxy/blocklist.conf

sudo touch /etc/privoxy/blocklist.conf

After this step, we must edit the file /etc/privoxy/blocklist.conf

sudo nano blocklist.conf

And place the following content in it:

# Config of privoxy-blocklist

array of URL for AdblockPlus lists

for more sources just add it within the round brackets

URLS=(
"https://easylist-downloads.adblockplus.org/malwaredomains_full.txt"
"https://easylist-downloads.adblockplus.org/fanboy-social.txt"
"https://easylist-downloads.adblockplus.org/easyprivacy.txt"
"https://easylist-downloads.adblockplus.org/easylist.txt"
"https://easylist-downloads.adblockplus.org/easylistdutch.txt"
)

config for privoxy initscript providing PRIVOXY_CONF, PRIVOXY_USER and PRIVOXY_GROUP

#INIT_CONF="/etc/conf.d/privoxy"

!! if the config above doesn't exist set these variables here !!

!! These values will be overwritten by INIT_CONF !!

PRIVOXY_USER="root"
PRIVOXY_GROUP="root"
PRIVOXY_CONF="/etc/privoxy/config"

name for lock file (default: script name)

TMPNAME="$(basename ${0})"

directory for temporary files

TMPDIR="/tmp/${TMPNAME}"

Debug-level

-1 = quiet

0 = normal

1 = verbose

2 = more verbose (debugging)

3 = incredibly loud (function debugging)

DBG=0

As you will see in this case, the lists are used Malware Domains, Fanboy-Social, EasyPrivacy and EasyList, in order to provide the script with blocking lists, it is from these lists that the domains that will be blocked by privoxy, being able to add more if desired.

Copied this, save the content and proceed to run the script using the following command, be sure to use bash instead of sh, since the last one gives an error preventing its execution.

sudo bash privoxy-blocklist.sh

With this, the script will begin to work showing the different steps it is doing at that moment, while configuring everything. Now to finish we have to restart the services, and for this we can use:

With SysVinit:
sudo service privoxy stop
sudo service privoxy start

With SystemD:
sudo systemctl stop privoxy
sudo systemctl start privoxy

And then we configure the proxy for our favorite browser or if we use KDE o GNOME, we can use the global configuration of our DE to make our entire system use the proxy every time it connects to the internet, with which we will stop seeing the annoying advertising, without having to have installed any add-on in our browser that is dedicated to it.

In order to make the lists update periodically, we can create a crontab, with the following command:

sudo crontab -e

And we add the following line:

@weekly /etc/privoxy/privoxy-blocklist.sh

We save the file and with this we make sure that the filters are updated weekly and thus keep our protection against advertising active.

Finally ... Why complicate your life if AdBlock Plus does its job well?

Surely after reading all this testament of codes and others, they will ask themselves this question or a very similar one, Why complicate your life if Adblock Plus does its job well?.

Well the truth is that yes, AdBlock Plus it does a good job but its impact on navigation leaves much to be desired, surely many have realized that if they load many filters, navigation is clearly hindered in terms of speed, in addition to that the increase in memory consumption shoots up significantly.

Use privoxy With this configuration, this detail is taken out of the way, since the impact on navigation is kept to a minimum (not to say null) and memory consumption decreases considerably.

The differences don't end there, the complement change from ABP by privoxy, it also allows the browser to start more quickly, since it is unnecessary to load the plugin configuration and the various selected lists.

There is also the fact that many browsers do not provide a very good ad blocking solution, and in this case Privoxy can very well provide such functionality locally and even on networks.

In the case of giving figures, in my particular case using Iceweasel 24 with AdBlock Plus + 3 tabs, Iceweasel consumes 332 Mb of memory, while Iceweasel 24 using Privoxy and those same three tabs, ends up consuming 162 Mb, a 170 Mb reduction in memory consumption, which is a fairly substantial improvement and with hardly any negative impact on processor occupancy.

To show this I leave you some screenshots:

Iceweasel_Privoxy

Iceweasel_Privoxy

Iceweasel_ABP

Iceweasel_ABP

This will give you a more than clear idea of ​​how useful and optimal it is to use this software. I hope you liked this article and it is of your benefit, until next time.

SOURCE: ALW-Home


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.   pandev92 said

    mhh it is not convenient to have it like that, because when you want to remove the adblock from a page only or from a domain, you have to re-edit everything, instead of just clicking.

    1.    yukiteru said

      Yes, it is the downside of the method, but the truth is that we rarely do that kind of personalized thing. However, the fix for this is quick, just temporarily disable the proxy and you will see the advertising of a certain site.

  2.   Nebuchadnezzar said

    You are a master my good Yukiteru !!!!
    You have helped me MANY times from the forum when I put my hand in my system and I c * oo it and now this. THANKS!!

    1.    yukiteru said

      No need to friend, for that we are here on the Blog and in the Forum to inform and help the community and users. In addition, experimenting, breaking and fixing you learn a lot, it is just a matter of having time, dedication and patience to do everything without it ending up getting out of hand.

      Greetings.

  3.   trisquelcolombia said

    Friend, is there an easy way to check if it is running to me? I entered pages after doing that and I see some advertising, thanks

    1.    yukiteru said

      To check that Privoxy is running you can use the command:

      For SystemD: sudo systemctl status privoxy
      For SysVinit: sudo service privoxy status

      These will return an output indicating if the service is active.

      The other thing that you have to check is that you are actually redirecting the Web traffic through the proxy, to achieve that you can use the Advanced Network Configuration of your browser, assigning the address 127.0.0.1 and port 8118 as proxy. Or if you use Gnome or KDE, set the environment variables so that they make use of the proxy pointing the same address.

      1.    trisquelcolombia said

        privoxy is not running. that got me the terminal. Is it because I restarted the pc, should I add something so that it always runs when I start?

        1.    yukiteru said

          To activate services in Debian you must use:

          For SystemD:
          sudo systemctl enable privoxy
          sudo systemctl start privoxy

          For SysVinit:
          sudo update-rc.d privoxy defaults
          sudo service privoxy start

          With these commands you activate the boot of the daemon and start executing it at once.

          1.    trisquelcolombia said

            I applied those two commands and then I checked again and it came out:

            root @: / home / mauro # sudo service privoxy status
            *privoxy is not running

        2.    yukiteru said

          Your problem is very rare, if you have followed the instructions at the foot of the letters you should not have problems, in your case I would check the file / var / log / syslog and /var/log/privoxy/privoxy.log in search of the specific problem that it avoids make privoxy run correctly.

          1.    mmm said

            I have the same problem as the person above and I found this in the log «Fatal error: can't bind to localhost: 8118: There may be another Privoxy or some other proxy running on port 8118 ″ ………………… ? ¿????? what's up, I have nothing running….
            regards

        3.    yukiteru said

          "Fatal error: can't bind to localhost: 8118: There may be another Privoxy or some other proxy running on port 8118"

          In this case, you can try using another port, putting 127.0.0.1:3127 and configuring the proxy in the browser pointing to the new port. Don't forget to stop and restart the service at this point so that the configuration is validated again.

        4.    cobynighter said

          Hola!

          In my case I had the same problem, this which indicates in Christian words is that two proxies are starting on the same port, the solution is simple to comment on the line (# listen-address localhost: 8118) and add the line indicated in post (listen-address 127.0.0.1:8118).

          Then open a terminal and run the following
          sudo stop service privoxy
          sudo service privoxy start
          sudo service privoxy status

          The latter should indicate that it is active!
          Greetings.

  4.   Miguel said

    It looks really good, especially since it doesn't use memory. just 2 queries, in case anyone knows:

    What does it mean to be a no-cache proxy?

    Is it the same as modifying the Host file?

    1.    yukiteru said

      In simple words, Privoxy is a content control proxy, and not a cache proxy, because the role of Privoxy is network and privacy filtering and not speeding up a connection using a cache, which is practically an «index of contents »stored on your PC locally, so that if you need something, you don't have to re-download the information from the server but only receive it from the proxy cache, saving you some time and bandwidth.

      A proxy cache can be done using Squid or the simple Polipo, both of which have the ability to do this task that in many cases in companies or small networks turns out to be quite beneficial, especially if your connection with the ISP is quite slow.

  5.   mmm said

    Hi. Thank you very much for this, very good. I hate advertising. But I had a question ... I use Ubuntu and I wanted to ask you if you can tell me how to stop the program to see if it is working or not, see if it blocked or not.
    Probe with sudo service privoxy stop… and it remains the same, nothing changes… how can I know if it is working, and turn it off whenever I want ???
    Saludos y gracias

    1.    yukiteru said

      In Ubuntu Upstart is used at the moment to manage services, to know if a certain service is running you can use this command:

      sudo status privoxy

      This will let you know if the service is running on your system.

  6.   mmm said

    I had missed this step.
    «We can use the global configuration of our DEs to make our entire system use the proxy every time it connects to the internet, with which we will stop seeing the annoying advertising, without having to have installed any add-on in our browser that is dedicated to it."

    How can I do that in Ubuntu ???? ' Cheers!

    1.    yukiteru said

      To configure a proxy in Ubuntu at the DE (Unity) level you must look for the Red utility in the Dash, and look for the Network Proxy section, there you can make the required changes, filling the fields with the address 127.0.0.1 and port 8118.

      1.    mmm said

        Hey.
        Thanks again for the post and for the time you take to clarify doubts.
        Regards

        1.    yukiteru said

          To the order mate, anything we are for the forum. http://foro.desdelinux.net

  7.   tabris said

    Couldn't the proxy be transparent?

    1.    yukiteru said

      Privoxy is not a transparent proxy. To make a proxy transparent you must use proxy software like Squid and configure it to run that way, however Privoxy can be used in conjunction with Squid to provide ad filtering while allowing Squid to run as a transparent proxy fulfilling what you want.

      For more information on this topic you can read:
      http://www.privoxy.org/faq/configuration.html

  8.   eliotime3000 said

    That is really interesting. Also, does that require a lot of processor work? Since I want to test it on my brand new HP Mini 110-3137la I recently installed 64-bit Debian Wheezy with XFCE.

    1.    yukiteru said

      @ eliotime3000, the processor consumption is negligible, just 2 or 3% while the page is loading, and then it returns to its original state, in addition, as shown in the screenshots I made, the memory consumption does improve remarkably, going to consume in In this case 170 Mb of memory less compared to ABP, and that in a computer with limited power and resources (as is my case with my Sempron) is something that is quite noticeable.

  9.   Mr. Polyphenol said

    Good. Perhaps my doubts are trivial but I still lack hands with Linux. I use Mint 15.

    "And then we configure the proxy for our favorite browser or if we use KDE or GNOME, we can use the global configuration of our DE [...]"
    Where can I find a clumsy guide to how to do this?

    "In order to make the lists update periodically, we can create a crontab [...]"
    When creating the crontab by default it saves it in the temporary folder. Is this the place to work?
    In etc / cron.weekly there is already a file, would it be enough to add the line "@weekly /etc/privoxy/privoxy-blocklist.sh" there?

    Thanks to all

    1.    yukiteru said

      Answering your first question, the best and easiest thing is to modify the / etc / envoiriment file by adding the following lines;

      http_proxy = http: //127.0.0.1: 8118 /
      https_proxy = http: //127.0.0.1: 8118 /
      ftp_proxy = http: //127.0.0.1: 8118 /
      no_proxy = »localhost, 127.0.0.1, localaddress, .localdomain.com»
      HTTP_PROXY = http: //127.0.0.1: 8118 /
      HTTPS_PROXY = http: //127.0.0.1: 8118 /
      FTP_PROXY = http: //127.0.0.1: 8118 /
      NO_PROXY = »localhost, 127.0.0.1, localaddress, .localdomain.com»

      Or you can find the Network options of the Linux Mint desktop and configure the Proxy from there.

      And as for your second question, the crontab command as it is is fully functional, and certainly if you already have a cron file created you can simply add the line to it to have the same functionality.

      1.    Mr. Polyphenol said

        Running… Wonderful!
        The truth is that editing the file is much simpler than the network assistant for those like me with fair knowledge.

        Thank you so much for the help, really, great job.
        All the best

  10.   rawBasic said

    Excellent .. ..thank you very much for the guide ..

    I applied it in ArchLinux (it is also in the official repos) .. ..changing the bind of '+ block-as-image' so that it does not show anything in the place of blocked ad ..

    I did not know it and it has power for even more complex things .. I hope we will see other posts on the subject .. 😉

    1.    yukiteru said

      It is good that you liked trying this tool and it is certainly very powerful and flexible.

    2.    cobynighter said

      Hello
      Could you tell me where I add that line? (+ block-as-image)

      Thank you very much in advance.

      1.    yukiteru said

        This rule goes in every .action file created by the script, in addition to being pointed in the user.action and default.action file.

    3.    juanra20 said

      Exactly what line does that go on? I know in the files that it goes further I'm not sure the line.

  11.   Jorge said

    I just did the test, and it is worth it indeed. However, I have noticed that the only advertising that has not been blocked is that of Facebook.

    It is also appreciated to put information on where to find more files with blocking filters, if not, it does not matter, thanks 😀

    1.    yukiteru said

      Editing the configuration file /etc/privoxy/blocklist.conf you will find a section of URLs where you can put more filters without any problem following the given scheme, to get those lists you just have to go to the main page of the lists and copy the URLs you require, save the file and run the script again so that in this way the files are downloaded and the conversion is made. After that, you simply have to restart the daemon to make the new filters take effect.

      Official Block List Site: https://easylist.adblockplus.org/en/

    2.    yukiteru said

      By the way very good personal website that you have made 🙂

      1.    Jorge said

        Yeah, I did the test and I still see the Facebook advertising, even with a filter I did:
        https://github.com/jorgicio/adblock-filters

        But anyway, I really appreciate the RAM saving it has left me, and for the rest, it does its job well 😀

        And thanks for the site, I did it entirely with VIM 😀

  12.   moscosov (@moscosov) said

    You passed, super good data, it must be said that I used (yes, it is past) Ad Block and I always work with many tabs open, usually 10 and sometimes more, which results in the browser, Firefox, sometimes consuming 800 Mb to 1.3 Gb, not to mention when it comes to using Chromium (my Institute's portal does not run well with Firefox) and now, after configuring Privoxy, with 14 tabs open in Firefox the consumption does not exceed 400 Mb, I insist one of the best How To I have read in the last time.

    On the other hand, if they use OpenSuse, the enabling of the Proxy is not done in the DE options, it must be done by changing and adding the values ​​by hand in / etc / sysconfig / proxy or in YAST in the section Editor for / etc / sysconfig files .

    That friend, you are grateful for the great tutorial, I share it and advertise it on my networks.

    1.    yukiteru said

      There is no partner, the purpose was that, to make known a little-known tool but with enormous potential that would allow to block advertising in a simple way, saving resources, hindering navigation very little and that was capable of providing such functionality to any browser used in the system.

      And as I always say, knowledge is free, so you are free to pass this information on.

      Greetings.

  13.   Alexander ponce said

    Thank you so much for sharing it.

  14.   cobynighter said

    Hello !

    I have a question, does this procedure do the same as when we modify the hosts file?
    I do not know if I explain myself.
    I mean this https://blog.desdelinux.net/bloquear-la-publicidad-de-internet-mediante-la-terminal-para-cualquier-navegador-sin-usar-plugins/

    On the other hand, when blocking the advertising of the pages, do they look like this?
    http://i.imgur.com/zyhmMe5.png

    Thanks in advance.

    1.    yukiteru said

      It does something similar to modifying the / etc / hosts file since it does not allow a certain resource to load when we browse, that is, it blocks it before it loads. The point is that the hosts file is a bit more complicated to maintain because you have to specify the entire domain, whereas with Privoxy you only have to specify a series of "keywords" or "key domains" to block content that matches. With these rules, it is therefore more effective blocking a greater diversity of advertising.

    2.    yukiteru said

      As for the "Unable connect" message of the browser, it is perfectly normal since it is due to the blocking of advertising, and what it means is that the web resource is blocked.

      1.    cobynighter said

        If I know, I was just reading that if we don't want to see said square we add the action [b] + handle-as-image [/ b]. This action modifies the code of the web page so as not to show these visual annoyances.

        I will try…

        1.    Jorge said

          I tried adding the handle-as-image, and it still doesn't work for me. On some pages, a giant blank space remains.

  15.   gongui said

    Is it me or the lists can't be downloaded from firefox and wget? From chrome you can access.

  16.   MegaMauritius said

    It takes a bit to make the adjustments but it is surprising to see it working. Thanks for sharing this information, especially for those of us who use Linux. 🙂

  17.   Mr. Polyphenol said

    Even though I'm still fiddling with privoxy, I'm still reluctant to add exceptions to seamlessly view pages like grooveshark. Any suggestions how I could do that?

    Thanks to all

    1.    MegaManuricio said

      You can try using nuvola player to navigate grooveshark without problems.

      1.    Mr. Polyphenol said

        Interesting about Nuvola although I don't think it works. More than anything because Privoxy acts on all connections and is also affected.
        I've tried setting up Privoxy with a manual but can't figure out what needs to be allowed for Grooveshark and so far the trial and error trials have been unsuccessful.
        But thank you very much, I think I will use Nuvola as soon as it clears me with privoxy.

  18.   Victor vargas said

    Hello to me, it worked very well and I really liked the solution but I have a problem that I would like you to help me solve, it works too well and blocks me from empathy and thunderbird, I mean, it won't let me receive emails, or connect to chat, You might say that I have to change the settings to output these two programs.

    In advance Thank you very much for the solution

  19.   fullmaster27 said

    Hello, how do I add the nauscopic filters?

  20.   Javier said

    Hi. As I see that you handle yourself quite well on the subject, I want to ask you why Privoxy blocks some pages from me, like MercadolLibre for example.
    How can I configure the filters.
    Thank you.