Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Tool of the Month: Privoxy


UnixReview.com
June 2005

Tool of the Month: Privoxy

by Joe "Zonker" Brockmeier

Like many sys admins, I spend a lot of time browsing the Internet. Probably too much, but that's one of the occupational hazards of being in front of a computer all day. After spending this much time at the computer, I'm heartily sick of animated banner ads, sites trying to set cookies behind my back, various JavaScript annoyances, and so forth. Now, Firefox does a brilliant job of smacking down a lot of pop-ups and other JavaScript annoyances and can take care of some of the cookie issues, but I wanted something in addition to Firefox. That's where Privoxy comes in. Privoxy is based on Internet Junkbuster but includes a number of improvements and new features.

Privoxy can be used to filter Web content, de-animate GIFs, block ads, bypass script redirection, and so forth. In short, Privoxy is a tool for privacy protection and eliminating junk from your browsing experience. It works as a proxy between your browser and the rest of the Internet, so that it can filter out incoming junk and filter outbound personal information as well.

Getting Privoxy

The Privoxy source code, and binary packages for several OSes, are available through SourceForge. Privoxy runs on Linux, Mac OS X, Solaris, NetBSD, FreeBSD, and many other OSes.

I'm using Privoxy on an Ubuntu "Hoary Hedgehog" system, so I just grabbed Privoxy with "apt-get install privoxy." The installation guide discusses installing binary packages and installing from source if your favorite *nix doesn't come with Privoxy packages.

Configuring and using Privoxy

Once Privoxy is installed, the next step is to fire it up and configure your browser to use Privoxy. By default, Privoxy is available on port 8118. To configure Firefox, for example, go to "Preferences," "General", and "Connection Settings." Select "Manual proxy configuration," and "Use the same proxy for all protocols."

Note that you can also configure Mozilla Thunderbird to use Privoxy if you happen to get a lot of HTML-ized email, or if you use Thunderbird as an RSS reader and want to filter the HTML you're seeing in Thunderbird. Actually, Privoxy works with a wide range of applications, so it might be worth testing with other applications that work with proxies.


Figure 1: Firefox preference dialog

Privoxy allows easy configuration editing through your browser. However, by default, this feature is turned off because it has no way to distinguish between users — so if multiple users are using the same installation of Privoxy, anyone can make changes, which may not be desirable. Since I'm using Privoxy on my desktop, and no one shares my PC, I prefer to configure Privoxy through my browser. To do this, edit Privoxy's configuration to change "enable-remote-toggle 0" to "enable-remote-toggle 1." On Ubuntu and Debian systems, the main Privoxy configuration file is /etc/privoxy/config. This may differ on other Linux distributions or Unixes.

Once that's set, take a look at the Privoxy browser configuration page. The Privoxy menu can be found by going to "http://config.privoxy.org/" once the browser is configured to use Privoxy as a proxy, or the even shorter "http://p.p/". From this page, you can see the current Privoxy configuration, view request headers sent by the browser, look up what actions Privoxy would take for a given URL, turn Privoxy off or on, or just go to the Privoxy local documentation. This page also tells you which version of Privoxy is running and has links to the Privoxy SourceForge page and support forums.


Figure 2: Privoxy menu

While experimenting with Privoxy, it's good to be able to quickly toggle Privoxy on and off to see how it's affecting the Web sites you visit. The "Toggle Privoxy on or off" page comes with several "bookmarklets" that make it easy to toggle its state.

To actually configure Privoxy, head to the "View & change the current configuration" page. Here you can view the standard.action configuration, and view and/or edit the default.action and user.action configuration files. These files control Privoxy's filtering actions. The order is progressive, with the standard, default, and then user actions processed. Actions in the user configuration take precedence over the actions in the default configuration, and so on.

The Privoxy actions are a bit complex, but the good news is that Privoxy's edit pages come with very detailed instructions. For example, by going to the edit page for the default.action configuration, you'll see a list of the possible default actions for all pages. Each action is linked to the documentation for that action, so it's easy to see what each configuration option means and what it will do.

If you're seeing weird behavior, or just want to know how Privoxy will handle a given page, go to "http://config.privoxy.org/show-url-info" — enter a URL on this page to see which Privoxy rules match content on the page and what would be done. This is a handy debugging tool if Privoxy isn't acting as you might expect.


Figure 3: Privoxy edit actions page

Privoxy also filters outgoing headers sent by the browser. To see what changes Privoxy makes, go to "http://config.privoxy.org/show-request." In the case of Firefox, Privoxy strips out "Accept-Encoding: gzip,deflate," the "Keep-Alive: 300" header. The Accept-Encoding: gzip,deflate outgoing header is removed so that servers do not send gzipped content back. This allows Privoxy to actually filter the content.

A look at the main Yahoo! Web page shows some of the content that Privoxy will block by default.


Figure 4: Blocked ads

In all, Privoxy is a handy tool for users who want to add an additional layer of privacy protection and ad blocking to their Web browsing. After using Privoxy for some time, I haven't noticed any major slowdown in browsing, or weird side effects that would make Privoxy hard to get along with. With Firefox's excellent pop-up blocking and privacy features and the Greasemonkey extension, browsing is still a pleasant and experience.

Send 'em in

As always, I'm on the lookout for additional tools and utilities that make life easier or more productive for users of Linux and other *nixes. If there's software under a free or open source license that you'd recommend, please feel free to drop me an email about it.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.