Filtering web pages with Privoxy


Privoxy is one of the web proxy applications (alternatives: Proxomitron, BFilter, etc.)that let you rewrite web pages on the fly. This can be used to remove ad banners, avoid downloading useless images, etc.

Trimming Privoxy to the bare minimum

The only files you need if you want to remove all the default settings that are shipped with the stock Privoxy are config.txt, user.action and user.filter.

Here's what config.txt should contain:

confdir .
logdir .
actionsfile user.action
filterfile user.filter
logfile privoxy.log
debug      1 # Log the destination for each request Privoxy let through.

#Change to IP address to share Privoxy with other hosts
toggle  1
enable-remote-toggle  0
enable-remote-http-toggle  0
enable-edit-actions 0
enforce-blocks 0
buffer-limit 4096
accept-intercepted-requests 0
split-large-forms 0
keep-alive-timeout 5
socket-timeout 300
handle-as-empty-doc-returns-ok 1

Then, just create a filter in user.action, and the related regexes in user.filter.

Customizing Privoxy


The main configuration file is named (in Windows) config.txt, and tells Privoxy which action files and filter files to load.


Privoxy provides about fifteen "actions", ie. tasks that it can perform when the users hits such and such URL such as "{ allow-all-cookies }". One of the actions is "filter{}", which can be used to refer to regexes located in user.filter and will be ran everytime the user hits the URL's listed for this action in user.action. Some Filters predefined in the supplied default.filter include "js-annoyances" and "content-cookies".

There are 4 types of lines in action files: comments, actions, aliases, and patterns (eg. "").


Note that you are free to choose the delimiter as you see fit. In addition to the Perl options gimsx, the following nonstandard options are supported:


Most of the default stuff is triggered in default.action. I would try
starting with the line that says {{alias}}, and delete from there on down.

standard.action is automatically invoked by privoxy, and will set some
defaults (including some filters possibly). This can be edited
manually or via the cgi editor of Privoxy.


All options in the config file except for confdir and logdir are optional. Watch out in the below description for what happens if you leave them unset.

confdir .

logdir .


actionsfile standard.action  # Internal purpose, recommended

actionsfile default.action   # Main actions file

actionsfile user.action      # User customizations

filterfile default.filter

filterfile user.filter      # User customizations


This is where user-specific actions should be put, as default.action may be overwritten when updating Privoxy.


How to apply a filter to all sites?