Synthetic commit for tag v_3_0_1
[privoxy.git] / doc / text / user-manual.txt
1 Privoxy 3.0.0 User Manual
2
3 Copyright © 2001, 2002 by Privoxy Developers
4
5 $Id: user-manual.sgml,v 1.123.2.18 2002/08/22 23:47:58 hal9 Exp $
6
7 The User Manual gives users information on how to install, configure and use 
8 Privoxy.
9
10 Privoxy is a web proxy with advanced filtering capabilities for protecting
11 privacy, filtering web page content, managing cookies, controlling access, and
12 removing ads, banners, pop-ups and other obnoxious Internet junk. Privoxy has a
13 very flexible configuration and can be customized to suit individual needs and
14 tastes. Privoxy has application for both stand-alone systems and multi-user
15 networks.
16
17 Privoxy is based on Internet Junkbuster (tm).
18
19 You can find the latest version of the User Manual at http://www.privoxy.org/
20 user-manual/. Please see the Contact section on how to contact the developers.
21
22 -------------------------------------------------------------------------------
23
24 Table of Contents
25 1. Introduction
26    
27     1.1. Features
28    
29 2. Installation
30    
31     2.1. Binary Packages
32        
33         2.1.1. Red Hat, SuSE and Conectiva RPMs
34         2.1.2. Debian
35         2.1.3. Windows
36         2.1.4. Solaris, NetBSD, FreeBSD, HP-UX
37         2.1.5. OS/2
38         2.1.6. Mac OSX
39         2.1.7. AmigaOS
40         2.1.8. Gentoo
41        
42     2.2. Building from Source
43     2.3. Keeping your Installation Up-to-Date
44    
45 3. Note to Upgraders
46 4. Quickstart to Using Privoxy
47    
48     4.1. Quickstart to Ad Blocking
49    
50 5. Starting Privoxy
51    
52     5.1. Red Hat and Conectiva
53     5.2. Debian
54     5.3. SuSE
55     5.4. Windows
56     5.5. Solaris, NetBSD, FreeBSD, HP-UX and others
57     5.6. OS/2
58     5.7. Mac OSX
59     5.8. AmigaOS
60     5.9. Gentoo
61     5.10. Command Line Options
62    
63 6. Privoxy Configuration
64    
65     6.1. Controlling Privoxy with Your Web Browser
66     6.2. Configuration Files Overview
67    
68 7. The Main Configuration File
69    
70     7.1. Configuration and Log File Locations
71        
72         7.1.1. confdir
73         7.1.2. logdir
74         7.1.3. actionsfile
75         7.1.4. filterfile
76         7.1.5. logfile
77         7.1.6. jarfile
78         7.1.7. trustfile
79        
80     7.2. Local Set-up Documentation
81        
82         7.2.1. user-manual
83         7.2.2. trust-info-url
84         7.2.3. admin-address
85         7.2.4. proxy-info-url
86        
87     7.3. Debugging
88        
89         7.3.1. debug
90         7.3.2. single-threaded
91        
92     7.4. Access Control and Security
93        
94         7.4.1. listen-address
95         7.4.2. toggle
96         7.4.3. enable-remote-toggle
97         7.4.4. enable-edit-actions
98         7.4.5. ACLs: permit-access and deny-access
99         7.4.6. buffer-limit
100        
101     7.5. Forwarding
102        
103         7.5.1. forward
104         7.5.2. forward-socks4 and forward-socks4a
105         7.5.3. Advanced Forwarding Examples
106        
107     7.6. Windows GUI Options
108    
109 8. Actions Files
110    
111     8.1. Finding the Right Mix
112     8.2. How to Edit
113     8.3. How Actions are Applied to URLs
114     8.4. Patterns
115        
116         8.4.1. The Domain Pattern
117         8.4.2. The Path Pattern
118        
119     8.5. Actions
120        
121         8.5.1. add-header
122         8.5.2. block
123         8.5.3. crunch-incoming-cookies
124         8.5.4. crunch-outgoing-cookies
125         8.5.5. deanimate-gifs
126         8.5.6. downgrade-http-version
127         8.5.7. fast-redirects
128         8.5.8. filter
129         8.5.9. handle-as-image
130         8.5.10. hide-forwarded-for-headers
131         8.5.11. hide-from-header
132         8.5.12. hide-referrer
133         8.5.13. hide-user-agent
134         8.5.14. kill-popups
135         8.5.15. limit-connect
136         8.5.16. prevent-compression
137         8.5.17. send-vanilla-wafer
138         8.5.18. send-wafer
139         8.5.19. session-cookies-only
140         8.5.20. set-image-blocker
141         8.5.21. Summary
142        
143     8.6. Aliases
144     8.7. Actions Files Tutorial
145        
146         8.7.1. default.action
147         8.7.2. user.action
148        
149 9. The Filter File
150    
151     9.1. Filter File Tutorial
152    
153 10. Templates
154 11. Contacting the Developers, Bug Reporting and Feature Requests
155    
156     11.1. Get Support
157     11.2. Report Bugs
158     11.3. Request New Features
159     11.4. Report Ads or Other Actions-Related Problems
160     11.5. Other
161    
162 12. Privoxy Copyright, License and History
163    
164     12.1. License
165     12.2. History
166     12.3. Authors
167    
168 13. See Also
169 14. Appendix
170    
171     14.1. Regular Expressions
172     14.2. Privoxy's Internal Pages
173        
174         14.2.1. Bookmarklets
175        
176     14.3. Chain of Events
177     14.4. Anatomy of an Action
178    
179 1. Introduction
180
181 This documentation is included with the current stable version of Privoxy,
182 v.3.0.0.
183
184 -------------------------------------------------------------------------------
185
186 1.1. Features
187
188 In addition to Internet Junkbuster's traditional features of ad and banner
189 blocking and cookie management, Privoxy provides new features:
190
191   * Integrated browser based configuration and control utility at http://
192     config.privoxy.org/ (shortcut: http://p.p/). Browser-based tracing of rule
193     and filter effects. Remote toggling.
194    
195   * Web page content filtering (removes banners based on size, invisible
196     "web-bugs", JavaScript and HTML annoyances, pop-up windows, etc.)
197    
198   * Modularized configuration that allows for standard settings and user
199     settings to reside in separate files, so that installing updated actions
200     files won't overwrite individual user settings.
201    
202   * HTTP/1.1 compliant (but not all optional 1.1 features are supported).
203    
204   * Support for Perl Compatible Regular Expressions in the configuration files,
205     and generally a more sophisticated and flexible configuration syntax over
206     previous versions.
207    
208   * Improved cookie management features (e.g. session based cookies).
209    
210   * GIF de-animation.
211    
212   * Bypass many click-tracking scripts (avoids script redirection).
213    
214   * Multi-threaded (POSIX and native threads).
215    
216   * User-customizable HTML templates for all proxy-generated pages (e.g.
217     "blocked" page).
218    
219   * Auto-detection and re-reading of config file changes.
220    
221   * Improved signal handling, and a true daemon mode (Unix).
222    
223   * Every feature now controllable on a per-site or per-location basis,
224     configuration more powerful and versatile over-all.
225    
226   * Many smaller new features added, limitations and bugs removed, and security
227     holes fixed.
228    
229 -------------------------------------------------------------------------------
230
231 2. Installation
232
233 Privoxy is available both in convenient pre-compiled packages for a wide range
234 of operating systems, and as raw source code. For most users, we recommend
235 using the packages, which can be downloaded from our Privoxy Project Page.
236
237 Note: If you have a previous Junkbuster or Privoxy installation on your system,
238 you will need to remove it. On some platforms, this may be done for you as part
239 of their installation procedure. (See below for your platform). In any case be
240 sure to backup your old configuration if it is valuable to you. See the note to
241 upgraders section below.
242
243 -------------------------------------------------------------------------------
244
245 2.1. Binary Packages
246
247 How to install the binary packages depends on your operating system:
248
249 -------------------------------------------------------------------------------
250
251 2.1.1. Red Hat, SuSE and Conectiva RPMs
252
253 RPMs can be installed with rpm -Uvh privoxy-3.0.0-1.rpm, and will use /etc/
254 privoxy for the location of configuration files.
255
256 Note that on Red Hat, Privoxy will not be automatically started on system boot.
257 You will need to enable that using chkconfig, ntsysv, or similar methods. Note
258 that SuSE will automatically start Privoxy in the boot process.
259
260 If you have problems with failed dependencies, try rebuilding the SRC RPM: rpm
261 --rebuild privoxy-3.0.0-1.src.rpm. This will use your locally installed
262 libraries and RPM version.
263
264 Also note that if you have a Junkbuster RPM installed on your system, you need
265 to remove it first, because the packages conflict. Otherwise, RPM will try to
266 remove Junkbuster automatically, before installing Privoxy.
267
268 -------------------------------------------------------------------------------
269
270 2.1.2. Debian
271
272 DEBs can be installed with dpkg -i privoxy_3.0.0-1.deb, and will use /etc/
273 privoxy for the location of configuration files.
274
275 -------------------------------------------------------------------------------
276
277 2.1.3. Windows
278
279 Just double-click the installer, which will guide you through the installation
280 process. You will find the configuration files in the same directory as you
281 installed Privoxy in. We do not use the registry of Windows.
282
283 -------------------------------------------------------------------------------
284
285 2.1.4. Solaris, NetBSD, FreeBSD, HP-UX
286
287 Create a new directory, cd to it, then unzip and untar the archive. For the
288 most part, you'll have to figure out where things go.
289
290 -------------------------------------------------------------------------------
291
292 2.1.5. OS/2
293
294 First, make sure that no previous installations of Junkbuster and / or Privoxy
295 are left on your system. Check that no Junkbuster or Privoxy objects are in
296 your startup folder. 
297
298 Then, just double-click the WarpIN self-installing archive, which will guide
299 you through the installation process. A shadow of the Privoxy executable will
300 be placed in your startup folder so it will start automatically whenever OS/2
301 starts.
302
303 The directory you choose to install Privoxy into will contain all of the
304 configuration files.
305
306 -------------------------------------------------------------------------------
307
308 2.1.6. Mac OSX
309
310 Unzip the downloaded file (you can either double-click on the file from the
311 finder, or from the desktop if you downloaded it there). Then, double-click on
312 the package installer icon named Privoxy.pkg and follow the installation
313 process. Privoxy will be installed in the folder /Library/Privoxy. It will
314 start automatically whenever you start up. To prevent it from starting
315 automatically, remove or rename the folder /Library/StartupItems/Privoxy.
316
317 To start Privoxy by hand, double-click on StartPrivoxy.command in the /Library/
318 Privoxy folder. Or, type this command in the Terminal:
319
320   /Library/Privoxy/StartPrivoxy.command                                        
321                                                                                
322
323 You will be prompted for the administrator password.
324
325 -------------------------------------------------------------------------------
326
327 2.1.7. AmigaOS
328
329 Copy and then unpack the lha archive to a suitable location. All necessary
330 files will be installed into Privoxy directory, including all configuration and
331 log files. To uninstall, just remove this directory.
332
333 -------------------------------------------------------------------------------
334
335 2.1.8. Gentoo
336
337 Gentoo source packages (Ebuilds) for Privoxy are contained in the Gentoo
338 Portage Tree (they are not on the download page, but there is a Gentoo section,
339 where you can see when a new Privoxy Version is added to the Portage Tree).
340
341 Before installing Privoxy under Gentoo just do first emerge rsync to get the
342 latest changes from the Portage tree. With emerge privoxy you install the
343 latest version.
344
345 Configuration files are in /etc/privoxy, the documentation is in /usr/share/doc
346 /privoxy-3.0.0 and the Log directory is in /var/log/privoxy.
347
348 -------------------------------------------------------------------------------
349
350 2.2. Building from Source
351
352 The most convenient way to obtain the Privoxy sources is to download the source
353 tarball from our project page.
354
355 If you like to live on the bleeding edge and are not afraid of using possibly
356 unstable development versions, you can check out the up-to-the-minute version
357 directly from the CVS repository or simply download the nightly CVS tarball.
358
359 To build Privoxy from source, autoconf, GNU make (gmake), and, of course, a C
360 compiler like gcc are required.
361
362 When building from a source tarball (either release version or nightly CVS
363 tarball), first unpack the source:
364
365  tar xzvf privoxy-3.0.0-src* [.tgz or .tar.gz]                                 
366  cd privoxy-3.0.0                                                              
367
368 For retrieving the current CVS sources, you'll need CVS installed. Note that
369 sources from CVS are development quality, and may not be stable, or well
370 tested. To download CVS source:
371
372   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login          
373   cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa co current 
374   cd current                                                                         
375
376 This will create a directory named current/, which will contain the source
377 tree.
378
379 Then, in either case, to build from unpacked tarball or CVS source:
380
381  autoheader                                                                    
382  autoconf                                                                      
383  ./configure      # (--help to see options)                                    
384  make             # (the make from gnu, gmake for *BSD)                        
385  su                                                                            
386  make -n install  # (to see where all the files will go)                       
387  make install     # (to really install)                                        
388
389 +-----------------------------------------------------------------------------+
390 |                                   Warning                                   |
391 |-----------------------------------------------------------------------------|
392 |The "make install" target is temporary quite broken! It is recommended to use|
393 |a binary package, or do a source build, and manually install the components. |
394 |Sorry.                                                                       |
395 +-----------------------------------------------------------------------------+
396
397 If you have gnu make, you can have the first four steps automatically done for
398 you by just typing:
399
400   make                                                                         
401
402 in the freshly downloaded or unpacked source directory.
403
404 For more detailed instructions on how to build Redhat and SuSE RPMs, Windows
405 self-extracting installers, building on platforms with special requirements
406 etc, please consult the developer manual.
407
408 -------------------------------------------------------------------------------
409
410 2.3. Keeping your Installation Up-to-Date
411
412 As user feedback comes in and development continues, we will make updated
413 versions of both the main actions file (as a separate package) and the software
414 itself (including the actions file) available for download.
415
416 If you wish to receive an email notification whenever we release updates of
417 Privoxy or the actions file, subscribe to our announce mailing list,
418 ijbswa-announce@lists.sourceforge.net.
419
420 In order not to loose your personal changes and adjustments when updating to
421 the latest default.action file we strongly recommend that you use user.action
422 for your customization of Privoxy. See the Chapter on actions files for
423 details.
424
425 -------------------------------------------------------------------------------
426
427 3. Note to Upgraders
428
429 There are very significant changes from earlier Junkbuster versions to the
430 current Privoxy. The number, names, syntax, and purposes of configuration files
431 have substantially changed. Junkbuster 2.0.x configuration files will not
432 migrate, Junkbuster 2.9.x and Privoxy configurations will need to be ported.
433 The functionalities of the old blockfile, cookiefile and imagelist are now
434 combined into the "actions files". default.action, is the main actions file.
435 Local exceptions should best be put into user.action.
436
437 A "filter file" (typically default.filter) is new as of Privoxy 2.9.x, and
438 provides some of the new sophistication (explained below). config is much the
439 same as before.
440
441 If upgrading from a 2.0.x version, you will have to use the new config files,
442 and possibly adapt any personal rules from your older files. When porting
443 personal rules over from the old blockfile to the new actions files, please
444 note that even the pattern syntax has changed. If upgrading from 2.9.x
445 development versions, it is still recommended to use the new configuration
446 files.
447
448 A quick list of things to be aware of before upgrading:
449
450   * The default listening port is now 8118 due to a conflict with another
451     service (NAS).
452    
453   * Some installers may remove earlier versions completely. Save any important
454     configuration files!
455    
456   * Privoxy is controllable with a web browser at the special URL: http://
457     config.privoxy.org/ (Shortcut: http://p.p/). Many aspects of configuration
458     can be done here, including temporarily disabling Privoxy.
459    
460   * The primary configuration files for cookie management, ad and banner
461     blocking, and many other aspects of Privoxy configuration are the actions
462     files. It is strongly recommended to become familiar with the new actions
463     concept below, before modifying these files. Locally defined rules should
464     go into user.action.
465    
466   * Some installers may not automatically start Privoxy after installation.
467    
468 -------------------------------------------------------------------------------
469
470 4. Quickstart to Using Privoxy
471
472   * If upgrading, from versions before 2.9.16, please back up any configuration
473     files. See the Note to Upgraders Section.
474    
475   * Install Privoxy. See the Installation Section below for platform specific
476     information.
477    
478   * Advanced users and those who want to offer Privoxy service to more than
479     just their local machine should check the main config file, especially the 
480     security-relevant options. These are off by default.
481    
482   * Start Privoxy, if the installation program has not done this already (may
483     vary according to platform). See the section Starting Privoxy.
484    
485   * Set your browser to use Privoxy as HTTP and HTTPS proxy by setting the
486     proxy configuration for address of 127.0.0.1 and port 8118. (Junkbuster and
487     earlier versions of Privoxy used port 8000.) See the section Starting
488     Privoxy below for more details on this.
489    
490   * Flush your browser's disk and memory caches, to remove any cached ad
491     images.
492    
493   * A default installation should provide a reasonable starting point for most.
494     There will undoubtedly be occasions where you will want to adjust the
495     configuration, but that can be dealt with as the need arises. Little to no
496     initial configuration is required in most cases.
497    
498     See the Configuration section for more configuration options, and how to
499     customize your installation.
500    
501   * If you experience ads that slipped through, innocent images that are
502     blocked, or otherwise feel the need to fine-tune Privoxy's behaviour, take
503     a look at the actions files. As a quick start, you might find the richly
504     commented examples helpful. You can also view and edit the actions files
505     through the web-based user interface. The Appendix "Anatomy of an Action"
506     has hints how to debug actions that "misbehave".
507    
508   * Please see the section Contacting the Developers on how to report bugs or
509     problems with websites or to get help.
510    
511   * Now enjoy surfing with enhanced comfort and privacy!
512    
513 -------------------------------------------------------------------------------
514
515 4.1. Quickstart to Ad Blocking
516
517 Ad blocking is but one of Privoxy's array of features. Many of these features
518 are for the technically minded advanced user. But, ad and banner blocking is
519 surely common ground for everybody.
520
521 This section will provide a quick summary of ad blocking so you can get up to
522 speed quickly without having to read the more extensive information provided
523 below, though this is highly recommended.
524
525 First a bit of a warning ... blocking ads is much like blocking SPAM: the more
526 aggressive you are about it, the more likely you are to block things that were
527 not intended. So there is a trade off here. If you want extreme ad free
528 browsing, be prepared to deal with more "problem" sites, and to spend more time
529 adjusting the configuration to solve these unintended consequences. In short,
530 there is not an easy way to eliminate all ads. Either take the easy way and
531 settle for most ads blocked with the default configuration, or jump in and
532 tweak it for your personal surfing habits and preferences.
533
534 Secondly, a brief explanation of Privoxy's "actions". "Actions" in this
535 context, are the directives we use to tell Privoxy to perform some task
536 relating to HTTP transactions (i.e. web browsing). We tell Privoxy to take some
537 "action". Each action has a unique name and function. While there are many
538 potential actions in Privoxy's arsenal, only a few are used for ad blocking. 
539 Actions, and action configuration files, are explained in depth below.
540
541 Actions are specified in Privoxy's configuration, followed by one or more URLs
542 to which the action should apply. URLs can actually be URL type patterns that
543 use wildcards so they can apply potentially to a range of similar URLs. The
544 actions, together with the URL patterns are called a section.
545
546 When you connect to a website, the full URL will either match one or more of
547 the sections as defined in Privoxy's configuration, or not. If so, then Privoxy
548 will perform the respective actions. If not, then nothing special happens.
549 Furthermore, web pages may contain embedded, secondary URLs that your web
550 browser will use to load additional components of the page, as it parses the
551 original page's HTML content. An ad image for instance, is just an URL embedded
552 in the page somewhere. The image itself may be on the same server, or a server
553 somewhere else on the Internet. Complex web pages will have many such embedded
554 URLs.
555
556 The actions we need to know about for ad blocking are: block, handle-as-image,
557 and set-image-blocker:
558
559   * block - this action stops any contact between your browser and any URL
560     patterns that match this action's configuration. It can be used for
561     blocking ads, but also anything that is determined to be unwanted. By
562     itself, it simply stops any communication with the remote server and sends
563     Privoxy's own built-in BLOCKED page instead to let you now what has
564     happened.
565    
566   * handle-as-image - tells Privoxy to treat this URL as an image. Privoxy's
567     default configuration already does this for all common image types (e.g.
568     GIF), but there are many situations where this is not so easy to determine.
569     So we'll force it in these cases. This is particularly important for ad
570     blocking, since only if we know that it's an image of some kind, can we
571     replace it with an image of our choosing, instead of the Privoxy BLOCKED
572     page (which would only result in a "broken image" icon). There are some
573     limitations to this though. For instance, you can't just brute-force an
574     image substitution for an entire HTML page in most situations.
575    
576   * set-image-blocker - tells Privoxy what to display in place of an ad image
577     that has hit a block rule. For this to come into play, the URL must match a
578     block action somewhere in the configuration, and, it must also match an 
579     handle-as-image action.
580    
581     The configuration options on what to display instead of the ad are:
582    
583        pattern - a checkerboard pattern, so that an ad replacement is obvious. 
584     This is the default.                                                       
585    
586        blank - A very small empty GIF image is displayed. This is the so-called
587     "invisible" configuration option.                                          
588    
589        http://<URL> - A redirect to any image anywhere of the user's choosing  
590     (advanced usage).                                                          
591    
592 The quickest way to adjust any of these settings is with your browser through
593 the special Privoxy editor at http://config.privoxy.org/show-status (shortcut: 
594 http://p.p/show-status). This is an internal page, and does not require
595 Internet access. Select the appropriate "actions" file, and click "Edit". It is
596 best to put personal or local preferences in user.action since this is not
597 meant to be overwritten during upgrades, and will over-ride the settings in
598 other files. Here you can insert new "actions", and URLs for ad blocking or
599 other purposes, and make other adjustments to the configuration. Privoxy will
600 detect these changes automatically.
601
602 A quick and simple step by step example:
603
604   * Right click on the ad image to be blocked, then select "Copy Link Location"
605     from the pop-up menu.
606    
607   * Set your browser to http://config.privoxy.org/show-status
608    
609   * Find user.action in the top section, and click on "Edit":
610    
611     Figure 1. Actions Files in Use
612    
613     [files-in-u]
614    
615   * You should have a section with only block listed under "Actions:". If not,
616     click a "Insert new section below" button, and in the new section that just
617     appeared, click the Edit button right under the word "Actions:". This will
618     bring up a list of all actions. Find block near the top, and click in the
619     "Enabled" column, then "Submit" just below the list.
620    
621   * Now, in the block actions section, click the "Add" button, and paste the
622     URL the browser got from "Copy Link Location". Remove the http:// at the
623     beginning of the URL. Then, click "Submit" (or "OK" if in a pop-up window).
624    
625   * Now go back to the original page, and press SHIFT-Reload (or flush all
626     browser caches). The image should be gone now.
627    
628 This is a very crude and simple example. There might be good reasons to use a
629 wildcard pattern match to include potentially similar images from the same
630 site. For a more extensive explanation of "patterns", and the entire actions
631 concept, see the Actions section.
632
633 For advanced users who want to hand edit their config files, you might want to
634 now go to the Actions Files Tutorial. The ideas explained therein also apply to
635 the web-based editor.
636
637 -------------------------------------------------------------------------------
638
639 5. Starting Privoxy
640
641 Before launching Privoxy for the first time, you will want to configure your
642 browser(s) to use Privoxy as a HTTP and HTTPS proxy. The default is 127.0.0.1
643 (or localhost) for the proxy address, and port 8118 (earlier versions used port
644 8000). This is the one configuration step that must be done!
645
646 Please note that Privoxy can only proxy HTTP and HTTPS traffic. It will not
647 work with FTP or other protocols.
648
649 Figure 2. Proxy Configuration (Mozilla)
650
651 [proxy_setu]
652
653 With Netscape (and Mozilla), this can be set under:
654
655  Edit
656    |_   
657          Preferences
658                 |_       
659                         Advanced
660                               |_     
661                                     Proxies
662                                          |_       
663                                                 HTTP Proxy
664
665 For Internet Explorer:
666
667  Tools
668      |_   
669          Internet Properties
670                             |_       
671                                       Connections
672                                                |_     
673                                                             LAN Settings
674
675 Then, check "Use Proxy" and fill in the appropriate info (Address: 127.0.0.1,
676 Port: 8118). Include HTTPS (SSL), if you want HTTPS proxy support too.
677
678 After doing this, flush your browser's disk and memory caches to force a
679 re-reading of all pages and to get rid of any ads that may be cached. You are
680 now ready to start enjoying the benefits of using Privoxy!
681
682 Privoxy is typically started by specifying the main configuration file to be
683 used on the command line. If no configuration file is specified on the command
684 line, Privoxy will look for a file named config in the current directory.
685 Except on Win32 where it will try config.txt.
686
687 -------------------------------------------------------------------------------
688
689 5.1. Red Hat and Conectiva
690
691 We use a script. Note that Red Hat does not start Privoxy upon booting per
692 default. It will use the file /etc/privoxy/config as its main configuration
693 file.
694
695  # /etc/rc.d/init.d/privoxy start                                              
696
697 -------------------------------------------------------------------------------
698
699 5.2. Debian
700
701 We use a script. Note that Debian starts Privoxy upon booting per default. It
702 will use the file /etc/privoxy/config as its main configuration file.
703
704  # /etc/init.d/privoxy start                                                   
705
706 -------------------------------------------------------------------------------
707
708 5.3. SuSE
709
710 We use a script. It will use the file /etc/privoxy/config as its main
711 configuration file. Note that SuSE starts Privoxy upon booting your PC.
712
713  # rcprivoxy start                                                             
714
715 -------------------------------------------------------------------------------
716
717 5.4. Windows
718
719 Click on the Privoxy Icon to start Privoxy. If no configuration file is
720 specified on the command line, Privoxy will look for a file named config.txt.
721 Note that Windows will automatically start Privoxy upon booting you PC.
722
723 -------------------------------------------------------------------------------
724
725 5.5. Solaris, NetBSD, FreeBSD, HP-UX and others
726
727 Example Unix startup command:
728
729  # /usr/sbin/privoxy /etc/privoxy/config                                       
730
731 -------------------------------------------------------------------------------
732
733 5.6. OS/2
734
735 During installation, Privoxy is configured to start automatically when the
736 system restarts. You can start it manually by double-clicking on the Privoxy
737 icon in the Privoxy folder.
738
739 -------------------------------------------------------------------------------
740
741 5.7. Mac OSX
742
743 During installation, Privoxy is configured to start automatically when the
744 system restarts. To start Privoxy by hand, double-click on the
745 StartPrivoxy.command icon in the /Library/Privoxy folder. Or, type this command
746 in the Terminal:
747
748   /Library/Privoxy/StartPrivoxy.command                                        
749                                                                                
750
751 You will be prompted for the administrator password.
752
753 -------------------------------------------------------------------------------
754
755 5.8. AmigaOS
756
757 Start Privoxy (with RUN <>NIL:) in your startnet script (AmiTCP), in s:
758 user-startup (RoadShow), as startup program in your startup script (Genesis),
759 or as startup action (Miami and MiamiDx). Privoxy will automatically quit when
760 you quit your TCP/IP stack (just ignore the harmless warning your TCP/IP stack
761 may display that Privoxy is still running).
762
763 -------------------------------------------------------------------------------
764
765 5.9. Gentoo
766
767 A script is again used. It will use the file /etc/privoxy/config as its main
768 configuration file.
769
770  /etc/init.d/privoxy start                                                     
771                                                                                
772
773 Note that Privoxy is not automatically started at boot time by default. You can
774 change this with the rc-update command.
775
776  rc-update add privoxy default                                                 
777                                                                                
778
779 -------------------------------------------------------------------------------
780
781 5.10. Command Line Options
782
783 Privoxy may be invoked with the following command-line options:
784
785   * --version
786    
787     Print version info and exit. Unix only.
788    
789   * --help
790    
791     Print short usage info and exit. Unix only.
792    
793   * --no-daemon
794    
795     Don't become a daemon, i.e. don't fork and become process group leader, and
796     don't detach from controlling tty. Unix only.
797    
798   * --pidfile FILE
799    
800     On startup, write the process ID to FILE. Delete the FILE on exit. Failure
801     to create or delete the FILE is non-fatal. If no FILE option is given, no
802     PID file will be used. Unix only.
803    
804   * --user USER[.GROUP]
805    
806     After (optionally) writing the PID file, assume the user ID of USER, and if
807     included the GID of GROUP. Exit if the privileges are not sufficient to do
808     so. Unix only.
809    
810   * configfile
811    
812     If no configfile is included on the command line, Privoxy will look for a
813     file named "config" in the current directory (except on Win32 where it will
814     look for "config.txt" instead). Specify full path to avoid confusion. If no
815     config file is found, Privoxy will fail to start.
816    
817 -------------------------------------------------------------------------------
818
819 6. Privoxy Configuration
820
821 All Privoxy configuration is stored in text files. These files can be edited
822 with a text editor. Many important aspects of Privoxy can also be controlled
823 easily with a web browser.
824
825 -------------------------------------------------------------------------------
826
827 6.1. Controlling Privoxy with Your Web Browser
828
829 Privoxy's user interface can be reached through the special URL http://
830 config.privoxy.org/ (shortcut: http://p.p/), which is a built-in page and works
831 without Internet access. You will see the following section: 
832
833      Privoxy Menu                                                              
834         ?  View & change the current configuration                             
835         ?  View the source code version numbers                                
836         ?  View the request headers.                                           
837         ?  Look up which actions apply to a URL and why                        
838         ?  Toggle Privoxy on or off                                            
839         ?  Documentation                                                       
840                                                                                
841
842 This should be self-explanatory. Note the first item leads to an editor for the
843 actions files, which is where the ad, banner, cookie, and URL blocking magic is
844 configured as well as other advanced features of Privoxy. This is an easy way
845 to adjust various aspects of Privoxy configuration. The actions file, and other
846 configuration files, are explained in detail below.
847
848 "Toggle Privoxy On or Off" is handy for sites that might have problems with
849 your current actions and filters. You can in fact use it as a test to see
850 whether it is Privoxy causing the problem or not. Privoxy continues to run as a
851 proxy in this case, but all manipulation is disabled, i.e. Privoxy acts like a
852 normal forwarding proxy. There is even a toggle Bookmarklet offered, so that
853 you can toggle Privoxy with one click from your browser.
854
855 -------------------------------------------------------------------------------
856
857 6.2. Configuration Files Overview
858
859 For Unix, *BSD and Linux, all configuration files are located in /etc/privoxy/
860 by default. For MS Windows, OS/2, and AmigaOS these are all in the same
861 directory as the Privoxy executable.
862
863 The installed defaults provide a reasonable starting point, though some
864 settings may be aggressive by some standards. For the time being, the principle
865 configuration files are:
866
867   * The main configuration file is named config on Linux, Unix, BSD, OS/2, and
868     AmigaOS and config.txt on Windows. This is a required file.
869    
870   * default.action (the main actions file) is used to define which "actions"
871     relating to banner-blocking, images, pop-ups, content modification, cookie
872     handling etc should be applied by default. It also defines many exceptions
873     (both positive and negative) from this default set of actions that enable
874     Privoxy to selectively eliminate the junk, and only the junk, on as many
875     websites as possible.
876    
877     Multiple actions files may be defined in config. These are processed in the
878     order they are defined. Local customizations and locally preferred
879     exceptions to the default policies as defined in default.action (which you
880     will most probably want to define sooner or later) are probably best
881     applied in user.action, where you can preserve them across upgrades.
882     standard.action is for Privoxy's internal use.
883    
884     There is also a web based editor that can be accessed from http://
885     config.privoxy.org/show-status (Shortcut: http://p.p/show-status) for the
886     various actions files.
887    
888   * default.filter (the filter file) can be used to re-write the raw page
889     content, including viewable text as well as embedded HTML and JavaScript,
890     and whatever else lurks on any given web page. The filtering jobs are only
891     pre-defined here; whether to apply them or not is up to the actions files.
892    
893 All files use the "#" character to denote a comment (the rest of the line will
894 be ignored) and understand line continuation through placing a backslash ("\")
895 as the very last character in a line. If the # is preceded by a backslash, it
896 looses its special function. Placing a # in front of an otherwise valid
897 configuration line to prevent it from being interpreted is called "commenting
898 out" that line.
899
900 The actions files and default.filter can use Perl style regular expressions for
901 maximum flexibility.
902
903 After making any changes, there is no need to restart Privoxy in order for the
904 changes to take effect. Privoxy detects such changes automatically. Note,
905 however, that it may take one or two additional requests for the change to take
906 effect. When changing the listening address of Privoxy, these "wake up"
907 requests must obviously be sent to the old listening address.
908
909 -------------------------------------------------------------------------------
910
911 7. The Main Configuration File
912
913 Again, the main configuration file is named config on Linux/Unix/BSD and OS/2,
914 and config.txt on Windows. Configuration lines consist of an initial keyword
915 followed by a list of values, all separated by whitespace (any number of spaces
916 or tabs). For example:
917
918   confdir /etc/privoxy
919
920 Assigns the value /etc/privoxy to the option confdir and thus indicates that
921 the configuration directory is named "/etc/privoxy/".
922
923 All options in the config file except for confdir and logdir are optional.
924 Watch out in the below description for what happens if you leave them unset.
925
926 The main config file controls all aspects of Privoxy's operation that are not
927 location dependent (i.e. they apply universally, no matter where you may be
928 surfing).
929
930 -------------------------------------------------------------------------------
931
932 7.1. Configuration and Log File Locations
933
934 Privoxy can (and normally does) use a number of other files for additional
935 configuration, help and logging. This section of the configuration file tells
936 Privoxy where to find those other files.
937
938 The user running Privoxy, must have read permission for all configuration
939 files, and write permission to any files that would be modified, such as log
940 files and actions files.
941
942 -------------------------------------------------------------------------------
943
944 7.1.1. confdir
945
946 Specifies:
947    
948     The directory where the other configuration files are located
949    
950 Type of value:
951    
952     Path name
953    
954 Default value:
955    
956     /etc/privoxy (Unix) or Privoxy installation dir (Windows)
957    
958 Effect if unset:
959    
960     Mandatory
961    
962 Notes:
963    
964     No trailing "/", please
965    
966     When development goes modular and multi-user, the blocker, filter, and
967     per-user config will be stored in subdirectories of "confdir". For now, the
968     configuration directory structure is flat, except for confdir/templates,
969     where the HTML templates for CGI output reside (e.g. Privoxy's 404 error
970     page).
971    
972 -------------------------------------------------------------------------------
973
974 7.1.2. logdir
975
976 Specifies:
977    
978     The directory where all logging takes place (i.e. where logfile and jarfile
979     are located)
980    
981 Type of value:
982    
983     Path name
984    
985 Default value:
986    
987     /var/log/privoxy (Unix) or Privoxy installation dir (Windows)
988    
989 Effect if unset:
990    
991     Mandatory
992    
993 Notes:
994    
995     No trailing "/", please
996    
997 -------------------------------------------------------------------------------
998
999 7.1.3. actionsfile
1000
1001 Specifies:
1002    
1003     The actions file(s) to use
1004    
1005 Type of value:
1006    
1007     File name, relative to confdir, without the .action suffix
1008    
1009 Default values:
1010    
1011       standard     # Internal purposes, no editing recommended
1012                                                               
1013       default      # Main actions file                        
1014                                                               
1015       user         # User customizations                      
1016    
1017 Effect if unset:
1018    
1019     No actions are taken at all. Simple neutral proxying.
1020    
1021 Notes:
1022    
1023     Multiple actionsfile lines are permitted, and are in fact recommended!
1024    
1025     The default values include standard.action, which is used for internal
1026     purposes and should be loaded, default.action, which is the "main" actions
1027     file maintained by the developers, and user.action, where you can make your
1028     personal additions.
1029    
1030     Actions files are where all the per site and per URL configuration is done
1031     for ad blocking, cookie management, privacy considerations, etc. There is
1032     no point in using Privoxy without at least one actions file.
1033    
1034 -------------------------------------------------------------------------------
1035
1036 7.1.4. filterfile
1037
1038 Specifies:
1039    
1040     The filter file to use
1041    
1042 Type of value:
1043    
1044     File name, relative to confdir
1045    
1046 Default value:
1047    
1048     default.filter (Unix) or default.filter.txt (Windows)
1049    
1050 Effect if unset:
1051    
1052     No textual content filtering takes place, i.e. all +filter{name} actions in
1053     the actions files are turned neutral.
1054    
1055 Notes:
1056    
1057     The filter file contains content modification rules that use regular
1058     expressions. These rules permit powerful changes on the content of Web
1059     pages, e.g., you could disable your favorite JavaScript annoyances,
1060     re-write the actual displayed text, or just have some fun replacing
1061     "Microsoft" with "MicroSuck" wherever it appears on a Web page.
1062    
1063     The +filter{name} actions rely on the relevant filter (name) to be defined
1064     in the filter file!
1065    
1066     A pre-defined filter file called default.filter that contains a bunch of
1067     handy filters for common problems is included in the distribution. See the
1068     section on the filter action for a list.
1069    
1070 -------------------------------------------------------------------------------
1071
1072 7.1.5. logfile
1073
1074 Specifies:
1075    
1076     The log file to use
1077    
1078 Type of value:
1079    
1080     File name, relative to logdir
1081    
1082 Default value:
1083    
1084     logfile (Unix) or privoxy.log (Windows)
1085    
1086 Effect if unset:
1087    
1088     No log file is used, all log messages go to the console (STDERR).
1089    
1090 Notes:
1091    
1092     The windows version will additionally log to the console.
1093    
1094     The logfile is where all logging and error messages are written. The level
1095     of detail and number of messages are set with the debug option (see below).
1096     The logfile can be useful for tracking down a problem with Privoxy (e.g.,
1097     it's not blocking an ad you think it should block) but in most cases you
1098     probably will never look at it.
1099    
1100     Your logfile will grow indefinitely, and you will probably want to
1101     periodically remove it. On Unix systems, you can do this with a cron job
1102     (see "man cron"). For Red Hat, a logrotate script has been included.
1103    
1104     On SuSE Linux systems, you can place a line like "/var/log/privoxy.* +1024k
1105     644 nobody.nogroup" in /etc/logfiles, with the effect that cron.daily will
1106     automatically archive, gzip, and empty the log, when it exceeds 1M size.
1107    
1108     Any log files must be writable by whatever user Privoxy is being run as
1109     (default on UNIX, user id is "privoxy").
1110    
1111 -------------------------------------------------------------------------------
1112
1113 7.1.6. jarfile
1114
1115 Specifies:
1116    
1117     The file to store intercepted cookies in
1118    
1119 Type of value:
1120    
1121     File name, relative to logdir
1122    
1123 Default value:
1124    
1125     jarfile (Unix) or privoxy.jar (Windows)
1126    
1127 Effect if unset:
1128    
1129     Intercepted cookies are not stored at all.
1130    
1131 Notes:
1132    
1133     The jarfile may grow to ridiculous sizes over time.
1134    
1135 -------------------------------------------------------------------------------
1136
1137 7.1.7. trustfile
1138
1139 Specifies:
1140    
1141     The trust file to use
1142    
1143 Type of value:
1144    
1145     File name, relative to confdir
1146    
1147 Default value:
1148    
1149     Unset (commented out). When activated: trust (Unix) or trust.txt (Windows)
1150    
1151 Effect if unset:
1152    
1153     The whole trust mechanism is turned off.
1154    
1155 Notes:
1156    
1157     The trust mechanism is an experimental feature for building white-lists and
1158     should be used with care. It is NOT recommended for the casual user.
1159    
1160     If you specify a trust file, Privoxy will only allow access to sites that
1161     are named in the trustfile. You can also mark sites as trusted referrers
1162     (with +), with the effect that access to untrusted sites will be granted,
1163     if a link from a trusted referrer was used. The link target will then be
1164     added to the "trustfile". Possible applications include limiting Internet
1165     access for children.
1166    
1167     If you use + operator in the trust file, it may grow considerably over
1168     time.
1169    
1170 -------------------------------------------------------------------------------
1171
1172 7.2. Local Set-up Documentation
1173
1174 If you intend to operate Privoxy for more users than just yourself, it might be
1175 a good idea to let them know how to reach you, what you block and why you do
1176 that, your policies, etc.
1177
1178 -------------------------------------------------------------------------------
1179
1180 7.2.1. user-manual
1181
1182 Specifies:
1183    
1184     Location of the Privoxy User Manual.
1185    
1186 Type of value:
1187    
1188     A fully qualified URI
1189    
1190 Default value:
1191    
1192     Unset
1193    
1194 Effect if unset:
1195    
1196     http://www.privoxy.org/version/user-manual/ will be used, where version is
1197     the Privoxy version.
1198    
1199 Notes:
1200    
1201     The User Manual URI is used for help links from some of the internal CGI
1202     pages. The manual itself is normally packaged with the binary
1203     distributions, so you probably want to set this to a locally installed
1204     copy. For multi-user setups, you could provide a copy on a local webserver
1205     for all your users and use the corresponding URL here.
1206    
1207     Examples:
1208    
1209     Unix, in local filesystem:
1210    
1211     user-manual  file:///usr/share/doc/privoxy-3.0.0/user-manual/      
1212    
1213     Any platform, on local webserver (called "local-webserver"):
1214    
1215     user-manual  http://local-webserver/privoxy-user-manual/           
1216    
1217     +-----------------------------------------------------------------+
1218     |                             Warning                             |
1219     |-----------------------------------------------------------------|
1220     |If set, this option should be the first option in the config     |
1221     |file, because it is used while the config file is being read.    |
1222     +-----------------------------------------------------------------+
1223
1224 -------------------------------------------------------------------------------
1225
1226 7.2.2. trust-info-url
1227
1228 Specifies:
1229    
1230     A URL to be displayed in the error page that users will see if access to an
1231     untrusted page is denied.
1232    
1233 Type of value:
1234    
1235     URL
1236    
1237 Default value:
1238    
1239     Two example URL are provided
1240    
1241 Effect if unset:
1242    
1243     No links are displayed on the "untrusted" error page.
1244    
1245 Notes:
1246    
1247     The value of this option only matters if the experimental trust mechanism
1248     has been activated. (See trustfile above.)
1249    
1250     If you use the trust mechanism, it is a good idea to write up some on-line
1251     documentation about your trust policy and to specify the URL(s) here. Use
1252     multiple times for multiple URLs.
1253    
1254     The URL(s) should be added to the trustfile as well, so users don't end up
1255     locked out from the information on why they were locked out in the first
1256     place!
1257    
1258 -------------------------------------------------------------------------------
1259
1260 7.2.3. admin-address
1261
1262 Specifies:
1263    
1264     An email address to reach the proxy administrator.
1265    
1266 Type of value:
1267    
1268     Email address
1269    
1270 Default value:
1271    
1272     Unset
1273    
1274 Effect if unset:
1275    
1276     No email address is displayed on error pages and the CGI user interface.
1277    
1278 Notes:
1279    
1280     If both admin-address and proxy-info-url are unset, the whole "Local
1281     Privoxy Support" box on all generated pages will not be shown.
1282    
1283 -------------------------------------------------------------------------------
1284
1285 7.2.4. proxy-info-url
1286
1287 Specifies:
1288    
1289     A URL to documentation about the local Privoxy setup, configuration or
1290     policies.
1291    
1292 Type of value:
1293    
1294     URL
1295    
1296 Default value:
1297    
1298     Unset
1299    
1300 Effect if unset:
1301    
1302     No link to local documentation is displayed on error pages and the CGI user
1303     interface.
1304    
1305 Notes:
1306    
1307     If both admin-address and proxy-info-url are unset, the whole "Local
1308     Privoxy Support" box on all generated pages will not be shown.
1309    
1310     This URL shouldn't be blocked ;-)
1311    
1312 -------------------------------------------------------------------------------
1313
1314 7.3. Debugging
1315
1316 These options are mainly useful when tracing a problem. Note that you might
1317 also want to invoke Privoxy with the --no-daemon command line option when
1318 debugging.
1319
1320 -------------------------------------------------------------------------------
1321
1322 7.3.1. debug
1323
1324 Specifies:
1325    
1326     Key values that determine what information gets logged to the logfile.
1327    
1328 Type of value:
1329    
1330     Integer values
1331    
1332 Default value:
1333    
1334     12289 (i.e.: URLs plus informational and warning messages)
1335    
1336 Effect if unset:
1337    
1338     Nothing gets logged.
1339    
1340 Notes:
1341    
1342     The available debug levels are:
1343    
1344       debug         1 # show each GET/POST/CONNECT request             
1345       debug         2 # show each connection status                    
1346       debug         4 # show I/O status                                
1347       debug         8 # show header parsing                            
1348       debug        16 # log all data into the logfile                  
1349       debug        32 # debug force feature                            
1350       debug        64 # debug regular expression filter                
1351       debug       128 # debug fast redirects                           
1352       debug       256 # debug GIF de-animation                         
1353       debug       512 # Common Log Format                              
1354       debug      1024 # debug kill pop-ups                             
1355       debug      2048 # CGI user interface                             
1356       debug      4096 # Startup banner and warnings.                   
1357       debug      8192 # Non-fatal errors                               
1358    
1359     To select multiple debug levels, you can either add them or use multiple
1360     debug lines.
1361    
1362     A debug level of 1 is informative because it will show you each request as
1363     it happens. 1, 4096 and 8192 are highly recommended so that you will notice
1364     when things go wrong. The other levels are probably only of interest if you
1365     are hunting down a specific problem. They can produce a hell of an output
1366     (especially 16).
1367    
1368     The reporting of fatal errors (i.e. ones which crash Privoxy) is always on
1369     and cannot be disabled.
1370    
1371     If you want to use CLF (Common Log Format), you should set "debug 512" ONLY
1372     and not enable anything else.
1373    
1374 -------------------------------------------------------------------------------
1375
1376 7.3.2. single-threaded
1377
1378 Specifies:
1379    
1380     Whether to run only one server thread
1381    
1382 Type of value:
1383    
1384     None
1385    
1386 Default value:
1387    
1388     Unset
1389    
1390 Effect if unset:
1391    
1392     Multi-threaded (or, where unavailable: forked) operation, i.e. the ability
1393     to serve multiple requests simultaneously.
1394    
1395 Notes:
1396    
1397     This option is only there for debug purposes and you should never need to
1398     use it. It will drastically reduce performance.
1399    
1400 -------------------------------------------------------------------------------
1401
1402 7.4. Access Control and Security
1403
1404 This section of the config file controls the security-relevant aspects of
1405 Privoxy's configuration.
1406
1407 -------------------------------------------------------------------------------
1408
1409 7.4.1. listen-address
1410
1411 Specifies:
1412    
1413     The IP address and TCP port on which Privoxy will listen for client
1414     requests.
1415    
1416 Type of value:
1417    
1418     [IP-Address]:Port
1419    
1420 Default value:
1421    
1422     127.0.0.1:8118
1423    
1424 Effect if unset:
1425    
1426     Bind to 127.0.0.1 (localhost), port 8118. This is suitable and recommended
1427     for home users who run Privoxy on the same machine as their browser.
1428    
1429 Notes:
1430    
1431     You will need to configure your browser(s) to this proxy address and port.
1432    
1433     If you already have another service running on port 8118, or if you want to
1434     serve requests from other machines (e.g. on your local network) as well,
1435     you will need to override the default.
1436    
1437     If you leave out the IP address, Privoxy will bind to all interfaces
1438     (addresses) on your machine and may become reachable from the Internet. In
1439     that case, consider using access control lists (ACL's, see below), and/or a
1440     firewall.
1441    
1442     If you open Privoxy to untrusted users, you will also want to turn off the 
1443     enable-edit-actions and enable-remote-toggle options!
1444    
1445 Example:
1446    
1447     Suppose you are running Privoxy on a machine which has the address
1448     192.168.0.1 on your local private network (192.168.0.0) and has another
1449     outside connection with a different address. You want it to serve requests
1450     from inside only:
1451    
1452       listen-address  192.168.0.1:8118                                 
1453    
1454 -------------------------------------------------------------------------------
1455
1456 7.4.2. toggle
1457
1458 Specifies:
1459    
1460     Initial state of "toggle" status
1461    
1462 Type of value:
1463    
1464     1 or 0
1465    
1466 Default value:
1467    
1468     1
1469    
1470 Effect if unset:
1471    
1472     Act as if toggled on
1473    
1474 Notes:
1475    
1476     If set to 0, Privoxy will start in "toggled off" mode, i.e. behave like a
1477     normal, content-neutral proxy where all ad blocking, filtering, etc are
1478     disabled. See enable-remote-toggle below. This is not really useful
1479     anymore, since toggling is much easier via the web interface than via
1480     editing the conf file.
1481    
1482     The windows version will only display the toggle icon in the system tray if
1483     this option is present.
1484    
1485 -------------------------------------------------------------------------------
1486
1487 7.4.3. enable-remote-toggle
1488
1489 Specifies:
1490    
1491     Whether or not the web-based toggle feature may be used
1492    
1493 Type of value:
1494    
1495     0 or 1
1496    
1497 Default value:
1498    
1499     1
1500    
1501 Effect if unset:
1502    
1503     The web-based toggle feature is disabled.
1504    
1505 Notes:
1506    
1507     When toggled off, Privoxy acts like a normal, content-neutral proxy, i.e.
1508     it acts as if none of the actions applied to any URL.
1509    
1510     For the time being, access to the toggle feature can not be controlled
1511     separately by "ACLs" or HTTP authentication, so that everybody who can
1512     access Privoxy (see "ACLs" and listen-address above) can toggle it for all
1513     users. So this option is not recommended for multi-user environments with
1514     untrusted users.
1515    
1516     Note that you must have compiled Privoxy with support for this feature,
1517     otherwise this option has no effect.
1518    
1519 -------------------------------------------------------------------------------
1520
1521 7.4.4. enable-edit-actions
1522
1523 Specifies:
1524    
1525     Whether or not the web-based actions file editor may be used
1526    
1527 Type of value:
1528    
1529     0 or 1
1530    
1531 Default value:
1532    
1533     1
1534    
1535 Effect if unset:
1536    
1537     The web-based actions file editor is disabled.
1538    
1539 Notes:
1540    
1541     For the time being, access to the editor can not be controlled separately
1542     by "ACLs" or HTTP authentication, so that everybody who can access Privoxy
1543     (see "ACLs" and listen-address above) can modify its configuration for all
1544     users. So this option is not recommended for multi-user environments with
1545     untrusted users.
1546    
1547     Note that you must have compiled Privoxy with support for this feature,
1548     otherwise this option has no effect.
1549    
1550 -------------------------------------------------------------------------------
1551
1552 7.4.5. ACLs: permit-access and deny-access
1553
1554 Specifies:
1555    
1556     Who can access what.
1557    
1558 Type of value:
1559    
1560     src_addr[/src_masklen] [dst_addr[/dst_masklen]]
1561    
1562     Where src_addr and dst_addr are IP addresses in dotted decimal notation or
1563     valid DNS names, and src_masklen and dst_masklen are subnet masks in CIDR
1564     notation, i.e. integer values from 2 to 30 representing the length (in
1565     bits) of the network address. The masks and the whole destination part are
1566     optional.
1567    
1568 Default value:
1569    
1570     Unset
1571    
1572 Effect if unset:
1573    
1574     Don't restrict access further than implied by listen-address
1575    
1576 Notes:
1577    
1578     Access controls are included at the request of ISPs and systems
1579     administrators, and are not usually needed by individual users. For a
1580     typical home user, it will normally suffice to ensure that Privoxy only
1581     listens on the localhost (127.0.0.1) or internal (home) network address by
1582     means of the listen-address option.
1583    
1584     Please see the warnings in the FAQ that this proxy is not intended to be a
1585     substitute for a firewall or to encourage anyone to defer addressing basic
1586     security weaknesses.
1587    
1588     Multiple ACL lines are OK. If any ACLs are specified, then the Privoxy
1589     talks only to IP addresses that match at least one permit-access line and
1590     don't match any subsequent deny-access line. In other words, the last match
1591     wins, with the default being deny-access.
1592    
1593     If Privoxy is using a forwarder (see forward below) for a particular
1594     destination URL, the dst_addr that is examined is the address of the
1595     forwarder and NOT the address of the ultimate target. This is necessary
1596     because it may be impossible for the local Privoxy to determine the IP
1597     address of the ultimate target (that's often what gateways are used for).
1598    
1599     You should prefer using IP addresses over DNS names, because the address
1600     lookups take time. All DNS names must resolve! You can not use domain
1601     patterns like "*.org" or partial domain names. If a DNS name resolves to
1602     multiple IP addresses, only the first one is used.
1603    
1604     Denying access to particular sites by ACL may have undesired side effects
1605     if the site in question is hosted on a machine which also hosts other
1606     sites.
1607    
1608 Examples:
1609    
1610     Explicitly define the default behavior if no ACL and listen-address are
1611     set: "localhost" is OK. The absence of a dst_addr implies that all
1612     destination addresses are OK:
1613    
1614       permit-access  localhost                                         
1615    
1616     Allow any host on the same class C subnet as www.privoxy.org access to
1617     nothing but www.example.com:
1618    
1619       permit-access  www.privoxy.org/24 www.example.com/32             
1620    
1621     Allow access from any host on the 26-bit subnet 192.168.45.64 to anywhere,
1622     with the exception that 192.168.45.73 may not access
1623     www.dirty-stuff.example.com:
1624    
1625       permit-access  192.168.45.64/26                                  
1626       deny-access    192.168.45.73    www.dirty-stuff.example.com      
1627    
1628 -------------------------------------------------------------------------------
1629
1630 7.4.6. buffer-limit
1631
1632 Specifies:
1633    
1634     Maximum size of the buffer for content filtering.
1635    
1636 Type of value:
1637    
1638     Size in Kbytes
1639    
1640 Default value:
1641    
1642     4096
1643    
1644 Effect if unset:
1645    
1646     Use a 4MB (4096 KB) limit.
1647    
1648 Notes:
1649    
1650     For content filtering, i.e. the +filter and +deanimate-gif actions, it is
1651     necessary that Privoxy buffers the entire document body. This can be
1652     potentially dangerous, since a server could just keep sending data
1653     indefinitely and wait for your RAM to exhaust -- with nasty consequences.
1654     Hence this option.
1655    
1656     When a document buffer size reaches the buffer-limit, it is flushed to the
1657     client unfiltered and no further attempt to filter the rest of the document
1658     is made. Remember that there may be multiple threads running, which might
1659     require up to buffer-limit Kbytes each, unless you have enabled
1660     "single-threaded" above.
1661    
1662 -------------------------------------------------------------------------------
1663
1664 7.5. Forwarding
1665
1666 This feature allows routing of HTTP requests through a chain of multiple
1667 proxies. It can be used to better protect privacy and confidentiality when
1668 accessing specific domains by routing requests to those domains through an
1669 anonymous public proxy (see e.g. http://www.multiproxy.org/anon_list.htm) Or to
1670 use a caching proxy to speed up browsing. Or chaining to a parent proxy may be
1671 necessary because the machine that Privoxy runs on has no direct Internet
1672 access.
1673
1674 Also specified here are SOCKS proxies. Privoxy supports the SOCKS 4 and SOCKS
1675 4A protocols.
1676
1677 -------------------------------------------------------------------------------
1678
1679 7.5.1. forward
1680
1681 Specifies:
1682    
1683     To which parent HTTP proxy specific requests should be routed.
1684    
1685 Type of value:
1686    
1687     target_pattern http_parent[:port]
1688    
1689     where target_pattern is a URL pattern that specifies to which requests
1690     (i.e. URLs) this forward rule shall apply. Use / to denote "all URLs".
1691     http_parent[:port] is the DNS name or IP address of the parent HTTP proxy
1692     through which the requests should be forwarded, optionally followed by its
1693     listening port (default: 8080). Use a single dot (.) to denote "no
1694     forwarding".
1695    
1696 Default value:
1697    
1698     Unset
1699    
1700 Effect if unset:
1701    
1702     Don't use parent HTTP proxies.
1703    
1704 Notes:
1705    
1706     If http_parent is ".", then requests are not forwarded to another HTTP
1707     proxy but are made directly to the web servers.
1708    
1709     Multiple lines are OK, they are checked in sequence, and the last match
1710     wins.
1711    
1712 Examples:
1713    
1714     Everything goes to an example anonymizing proxy, except SSL on port 443
1715     (which it doesn't handle):
1716    
1717       forward   /      anon-proxy.example.org:8080                     
1718       forward   :443   .                                               
1719    
1720     Everything goes to our example ISP's caching proxy, except for requests to
1721     that ISP's sites:
1722    
1723       forward   /                  caching-proxy.example-isp.net:8000  
1724       forward   .example-isp.net   .                                   
1725    
1726 -------------------------------------------------------------------------------
1727
1728 7.5.2. forward-socks4 and forward-socks4a
1729
1730 Specifies:
1731    
1732     Through which SOCKS proxy (and to which parent HTTP proxy) specific
1733     requests should be routed.
1734    
1735 Type of value:
1736    
1737     target_pattern socks_proxy[:port] http_parent[:port]
1738    
1739     where target_pattern is a URL pattern that specifies to which requests
1740     (i.e. URLs) this forward rule shall apply. Use / to denote "all URLs".
1741     http_parent and socks_proxy are IP addresses in dotted decimal notation or
1742     valid DNS names (http_parent may be "." to denote "no HTTP forwarding"),
1743     and the optional port parameters are TCP ports, i.e. integer values from 1
1744     to 64535
1745    
1746 Default value:
1747    
1748     Unset
1749    
1750 Effect if unset:
1751    
1752     Don't use SOCKS proxies.
1753    
1754 Notes:
1755    
1756     Multiple lines are OK, they are checked in sequence, and the last match
1757     wins.
1758    
1759     The difference between forward-socks4 and forward-socks4a is that in the
1760     SOCKS 4A protocol, the DNS resolution of the target hostname happens on the
1761     SOCKS server, while in SOCKS 4 it happens locally.
1762    
1763     If http_parent is ".", then requests are not forwarded to another HTTP
1764     proxy but are made (HTTP-wise) directly to the web servers, albeit through
1765     a SOCKS proxy.
1766    
1767 Examples:
1768    
1769     From the company example.com, direct connections are made to all "internal"
1770     domains, but everything outbound goes through their ISP's proxy by way of
1771     example.com's corporate SOCKS 4A gateway to the Internet.
1772    
1773       forward-socks4a   /              socks-gw.example.com:1080  www-cache.example-isp.net:8080 
1774       forward           .example.com   .                                                         
1775    
1776     A rule that uses a SOCKS 4 gateway for all destinations but no HTTP parent
1777     looks like this:
1778    
1779       forward-socks4   /               socks-gw.example.com:1080  .    
1780    
1781 -------------------------------------------------------------------------------
1782
1783 7.5.3. Advanced Forwarding Examples
1784
1785 If you have links to multiple ISPs that provide various special content only to
1786 their subscribers, you can configure multiple Privoxies which have connections
1787 to the respective ISPs to act as forwarders to each other, so that your users
1788 can see the internal content of all ISPs.
1789
1790 Assume that host-a has a PPP connection to isp-a.net. And host-b has a PPP
1791 connection to isp-b.net. Both run Privoxy. Their forwarding configuration can
1792 look like this:
1793
1794 host-a:
1795
1796   forward    /           .                                                     
1797   forward    .isp-b.net  host-b:8118                                           
1798
1799 host-b:
1800
1801   forward    /           .                                                     
1802   forward    .isp-a.net  host-a:8118                                           
1803
1804 Now, your users can set their browser's proxy to use either host-a or host-b
1805 and be able to browse the internal content of both isp-a and isp-b.
1806
1807 If you intend to chain Privoxy and squid locally, then chain as browser ->
1808 squid -> privoxy is the recommended way.
1809
1810 Assuming that Privoxy and squid run on the same box, your squid configuration
1811 could then look like this:
1812
1813   # Define Privoxy as parent proxy (without ICP)                               
1814   cache_peer 127.0.0.1 parent 8118 7 no-query                                  
1815                                                                                
1816   # Define ACL for protocol FTP                                                
1817   acl ftp proto FTP                                                            
1818                                                                                
1819   # Do not forward FTP requests to Privoxy                                     
1820   always_direct allow ftp                                                      
1821                                                                                
1822   # Forward all the rest to Privoxy                                            
1823   never_direct allow all                                                       
1824
1825 You would then need to change your browser's proxy settings to squid's address
1826 and port. Squid normally uses port 3128. If unsure consult http_port in
1827 squid.conf.
1828
1829 You could just as well decide to only forward requests for Windows executables
1830 through a virus-scanning parent proxy, say, on antivir.example.com, port 8010:
1831
1832   forward   /                          .                                       
1833   forward   /.*\.(exe|com|dll|zip)$    antivir.example.com:8010                
1834
1835 -------------------------------------------------------------------------------
1836
1837 7.6. Windows GUI Options
1838
1839 Privoxy has a number of options specific to the Windows GUI interface:
1840
1841 If "activity-animation" is set to 1, the Privoxy icon will animate when
1842 "Privoxy" is active. To turn off, set to 0.
1843
1844   activity-animation 1
1845    
1846
1847 If "log-messages" is set to 1, Privoxy will log messages to the console window:
1848
1849   log-messages 1
1850    
1851
1852 If "log-buffer-size" is set to 1, the size of the log buffer, i.e. the amount
1853 of memory used for the log messages displayed in the console window, will be
1854 limited to "log-max-lines" (see below).
1855
1856 Warning: Setting this to 0 will result in the buffer to grow infinitely and eat
1857 up all your memory!
1858
1859   log-buffer-size 1
1860    
1861
1862 log-max-lines is the maximum number of lines held in the log buffer. See above.
1863
1864   log-max-lines 200
1865    
1866
1867 If "log-highlight-messages" is set to 1, Privoxy will highlight portions of the
1868 log messages with a bold-faced font:
1869
1870   log-highlight-messages 1
1871    
1872
1873 The font used in the console window:
1874
1875   log-font-name Comic Sans MS
1876    
1877
1878 Font size used in the console window:
1879
1880   log-font-size 8
1881    
1882
1883 "show-on-task-bar" controls whether or not Privoxy will appear as a button on
1884 the Task bar when minimized:
1885
1886   show-on-task-bar 0
1887    
1888
1889 If "close-button-minimizes" is set to 1, the Windows close button will minimize
1890 Privoxy instead of closing the program (close with the exit option on the File
1891 menu).
1892
1893   close-button-minimizes 1
1894    
1895
1896 The "hide-console" option is specific to the MS-Win console version of Privoxy.
1897 If this option is used, Privoxy will disconnect from and hide the command
1898 console.
1899
1900   #hide-console
1901    
1902
1903 -------------------------------------------------------------------------------
1904
1905 8. Actions Files
1906
1907 The actions files are used to define what actions Privoxy takes for which URLs,
1908 and thus determine how ad images, cookies and various other aspects of HTTP
1909 content and transactions are handled, and on which sites (or even parts
1910 thereof). There are three such files included with Privoxy (as of version
1911 2.9.15), with differing purposes:
1912
1913   * default.action - is the primary action file that sets the initial values
1914     for all actions. It is intended to provide a base level of functionality
1915     for Privoxy's array of features. So it is a set of broad rules that should
1916     work reasonably well for users everywhere. This is the file that the
1917     developers are keeping updated, and making available to users.
1918    
1919   * user.action - is intended to be for local site preferences and exceptions.
1920     As an example, if your ISP or your bank has specific requirements, and need
1921     special handling, this kind of thing should go here. This file will not be
1922     upgraded.
1923    
1924   * standard.action - is used by the web based editor, to set various
1925     pre-defined sets of rules for the default actions section in
1926     default.action. These have increasing levels of aggressiveness and have no
1927     influence on your browsing unless you select them explicitly in the editor.
1928     It is not recommend to edit this file.
1929    
1930 The list of actions files to be used are defined in the main configuration
1931 file, and are processed in the order they are defined. The content of these can
1932 all be viewed and edited from http://config.privoxy.org/show-status.
1933
1934 An actions file typically has multiple sections. If you want to use "aliases"
1935 in an actions file, you have to place the (optional) alias section at the top
1936 of that file. Then comes the default set of rules which will apply universally
1937 to all sites and pages (be very careful with using such a universal set in
1938 user.action or any other actions file after default.action, because it will
1939 override the result from consulting any previous file). And then below that,
1940 exceptions to the defined universal policies. You can regard user.action as an
1941 appendix to default.action, with the advantage that is a separate file, which
1942 makes preserving your personal settings across Privoxy upgrades easier.
1943
1944 Actions can be used to block anything you want, including ads, banners, or just
1945 some obnoxious URL that you would rather not see. Cookies can be accepted or
1946 rejected, or accepted only during the current browser session (i.e. not written
1947 to disk), content can be modified, JavaScripts tamed, user-tracking fooled, and
1948 much more. See below for a complete list of actions.
1949
1950 -------------------------------------------------------------------------------
1951
1952 8.1. Finding the Right Mix
1953
1954 Note that some actions, like cookie suppression or script disabling, may render
1955 some sites unusable that rely on these techniques to work properly. Finding the
1956 right mix of actions is not always easy and certainly a matter of personal
1957 taste. In general, it can be said that the more "aggressive" your default
1958 settings (in the top section of the actions file) are, the more exceptions for
1959 "trusted" sites you will have to make later. If, for example, you want to kill
1960 popup windows per default, you'll have to make exceptions from that rule for
1961 sites that you regularly use and that require popups for actually useful
1962 content, like maybe your bank, favorite shop, or newspaper.
1963
1964 We have tried to provide you with reasonable rules to start from in the
1965 distribution actions files. But there is no general rule of thumb on these
1966 things. There just are too many variables, and sites are constantly changing.
1967 Sooner or later you will want to change the rules (and read this chapter again
1968 :).
1969
1970 -------------------------------------------------------------------------------
1971
1972 8.2. How to Edit
1973
1974 The easiest way to edit the actions files is with a browser by using our
1975 browser-based editor, which can be reached from http://config.privoxy.org/
1976 show-status. The editor allows both fine-grained control over every single
1977 feature on a per-URL basis, and easy choosing from wholesale sets of defaults
1978 like "Cautious", "Medium" or "Advanced".
1979
1980 If you prefer plain text editing to GUIs, you can of course also directly edit
1981 the the actions files. Look at default.action which is richly commented.
1982
1983 -------------------------------------------------------------------------------
1984
1985 8.3. How Actions are Applied to URLs
1986
1987 Actions files are divided into sections. There are special sections, like the "
1988 alias" sections which will be discussed later. For now let's concentrate on
1989 regular sections: They have a heading line (often split up to multiple lines
1990 for readability) which consist of a list of actions, separated by whitespace
1991 and enclosed in curly braces. Below that, there is a list of URL patterns, each
1992 on a separate line.
1993
1994 To determine which actions apply to a request, the URL of the request is
1995 compared to all patterns in each action file file. Every time it matches, the
1996 list of applicable actions for the URL is incrementally updated, using the
1997 heading of the section in which the pattern is located. If multiple matches for
1998 the same URL set the same action differently, the last match wins. If not, the
1999 effects are aggregated. E.g. a URL might match a regular section with a heading
2000 line of { +handle-as-image }, then later another one with just { +block },
2001 resulting in both actions to apply.
2002
2003 You can trace this process for any given URL by visiting http://
2004 config.privoxy.org/show-url-info.
2005
2006 More detail on this is provided in the Appendix, Anatomy of an Action.
2007
2008 -------------------------------------------------------------------------------
2009
2010 8.4. Patterns
2011
2012 Generally, a pattern has the form <domain>/<path>, where both the <domain> and
2013 <path> are optional. (This is why the pattern / matches all URLs).
2014
2015 www.example.com/
2016    
2017     is a domain-only pattern and will match any request to www.example.com,
2018     regardless of which document on that server is requested.
2019    
2020 www.example.com
2021    
2022     means exactly the same. For domain-only patterns, the trailing / may be
2023     omitted.
2024    
2025 www.example.com/index.html
2026    
2027     matches only the single document /index.html on www.example.com.
2028    
2029 /index.html
2030    
2031     matches the document /index.html, regardless of the domain, i.e. on any web
2032     server.
2033    
2034 index.html
2035    
2036     matches nothing, since it would be interpreted as a domain name and there
2037     is no top-level domain called .html.
2038    
2039 -------------------------------------------------------------------------------
2040
2041 8.4.1. The Domain Pattern
2042
2043 The matching of the domain part offers some flexible options: if the domain
2044 starts or ends with a dot, it becomes unanchored at that end. For example:
2045
2046 .example.com
2047    
2048     matches any domain that ENDS in .example.com
2049    
2050 www.
2051    
2052     matches any domain that STARTS with www.
2053    
2054 .example.
2055    
2056     matches any domain that CONTAINS .example. (Correctly speaking: It matches
2057     any FQDN that contains example as a domain.)
2058    
2059 Additionally, there are wild-cards that you can use in the domain names
2060 themselves. They work pretty similar to shell wild-cards: "*" stands for zero
2061 or more arbitrary characters, "?" stands for any single character, you can
2062 define character classes in square brackets and all of that can be freely
2063 mixed:
2064
2065 ad*.example.com
2066    
2067     matches "adserver.example.com", "ads.example.com", etc but not
2068     "sfads.example.com"
2069    
2070 *ad*.example.com
2071    
2072     matches all of the above, and then some.
2073    
2074 .?pix.com
2075    
2076     matches www.ipix.com, pictures.epix.com, a.b.c.d.e.upix.com etc.
2077    
2078 www[1-9a-ez].example.c*
2079    
2080     matches www1.example.com, www4.example.cc, wwwd.example.cy,
2081     wwwz.example.com etc., but not wwww.example.com.
2082    
2083 -------------------------------------------------------------------------------
2084
2085 8.4.2. The Path Pattern
2086
2087 Privoxy uses Perl compatible regular expressions (through the PCRE library) for
2088 matching the path.
2089
2090 There is an Appendix with a brief quick-start into regular expressions, and
2091 full (very technical) documentation on PCRE regex syntax is available on-line
2092 at http://www.pcre.org/man.txt. You might also find the Perl man page on
2093 regular expressions (man perlre) useful, which is available on-line at http://
2094 www.perldoc.com/perl5.6/pod/perlre.html.
2095
2096 Note that the path pattern is automatically left-anchored at the "/", i.e. it
2097 matches as if it would start with a "^" (regular expression speak for the
2098 beginning of a line).
2099
2100 Please also note that matching in the path is CASE INSENSITIVE by default, but
2101 you can switch to case sensitive at any point in the pattern by using the "(?
2102 -i)" switch: www.example.com/(?-i)PaTtErN.* will match only documents whose
2103 path starts with PaTtErN in exactly this capitalization.
2104
2105 -------------------------------------------------------------------------------
2106
2107 8.5. Actions
2108
2109 All actions are disabled by default, until they are explicitly enabled
2110 somewhere in an actions file. Actions are turned on if preceded with a "+", and
2111 turned off if preceded with a "-". So a +action means "do that action", e.g.
2112 +block means "please block URLs that match the following patterns", and -block
2113 means "don't block URLs that match the following patterns, even if +block
2114 previously applied." 
2115
2116 Again, actions are invoked by placing them on a line, enclosed in curly braces
2117 and separated by whitespace, like in {+some-action -some-other-action
2118 {some-parameter}}, followed by a list of URL patterns, one per line, to which
2119 they apply. Together, the actions line and the following pattern lines make up
2120 a section of the actions file.
2121
2122 There are three classes of actions:
2123
2124   * Boolean, i.e the action can only be "enabled" or "disabled". Syntax:
2125    
2126       +name        # enable action name                                
2127       -name        # disable action name                               
2128    
2129     Example: +block
2130    
2131   * Parameterized, where some value is required in order to enable this type of
2132     action. Syntax:
2133    
2134       +name{param}  # enable action and set parameter to param,             
2135                    # overwriting parameter from previous match if necessary 
2136       -name         # disable action. The parameter can be omitted          
2137    
2138     Note that if the URL matches multiple positive forms of a parameterized
2139     action, the last match wins, i.e. the params from earlier matches are
2140     simply ignored.
2141    
2142     Example: +hide-user-agent{ Mozilla 1.0 }
2143    
2144   * Multi-value. These look exactly like parameterized actions, but they behave
2145     differently: If the action applies multiple times to the same URL, but with
2146     different parameters, all the parameters from all matches are remembered.
2147     This is used for actions that can be executed for the same request
2148     repeatedly, like adding multiple headers, or filtering through multiple
2149     filters. Syntax:
2150    
2151       +name{param}   # enable action and add param to the list of parameters                 
2152       -name{param}   # remove the parameter param from the list of parameters                
2153                     # If it was the last one left, disable the action.                       
2154       -name          # disable this action completely and remove all parameters from the list
2155    
2156     Examples: +add-header{X-Fun-Header: Some text} and +filter{html-annoyances}
2157    
2158 If nothing is specified in any actions file, no "actions" are taken. So in this
2159 case Privoxy would just be a normal, non-blocking, non-anonymizing proxy. You
2160 must specifically enable the privacy and blocking features you need (although
2161 the provided default actions files will give a good starting point).
2162
2163 Later defined actions always over-ride earlier ones. So exceptions to any rules
2164 you make, should come in the latter part of the file (or in a file that is
2165 processed later when using multiple actions files). For multi-valued actions,
2166 the actions are applied in the order they are specified. Actions files are
2167 processed in the order they are defined in config (the default installation has
2168 three actions files). It also quite possible for any given URL pattern to match
2169 more than one pattern and thus more than one set of actions!
2170
2171 The list of valid Privoxy actions are:
2172
2173 -------------------------------------------------------------------------------
2174
2175 8.5.1. add-header
2176
2177 Typical use:
2178    
2179     Confuse log analysis, custom applications
2180    
2181 Effect:
2182    
2183     Sends a user defined HTTP header to the web server.
2184    
2185 Type:
2186    
2187     Multi-value.
2188    
2189 Parameter:
2190    
2191     Any string value is possible. Validity of the defined HTTP headers is not
2192     checked. It is recommended that you use the "X-" prefix for custom headers.
2193    
2194 Notes:
2195    
2196     This action may be specified multiple times, in order to define multiple
2197     headers. This is rarely needed for the typical user. If you don't know what
2198     "HTTP headers" are, you definitely don't need to worry about this one.
2199    
2200 Example usage:
2201    
2202     +add-header{X-User-Tracking: sucks}                                
2203    
2204 -------------------------------------------------------------------------------
2205
2206 8.5.2. block
2207
2208 Typical use:
2209    
2210     Block ads or other obnoxious content
2211    
2212 Effect:
2213    
2214     Requests for URLs to which this action applies are blocked, i.e. the
2215     requests are not forwarded to the remote server, but answered locally with
2216     a substitute page or image, as determined by the handle-as-image and 
2217     set-image-blocker actions.
2218    
2219 Type:
2220    
2221     Boolean.
2222    
2223 Parameter:
2224    
2225     N/A
2226    
2227 Notes:
2228    
2229     Privoxy sends a special "BLOCKED" page for requests to blocked pages. This
2230     page contains links to find out why the request was blocked, and a
2231     click-through to the blocked content (the latter only if compiled with the
2232     force feature enabled). The "BLOCKED" page adapts to the available screen
2233     space -- it displays full-blown if space allows, or miniaturized and
2234     text-only if loaded into a small frame or window. If you are using Privoxy
2235     right now, you can take a look at the "BLOCKED" page.
2236    
2237     A very important exception occurs if both block and handle-as-image, apply
2238     to the same request: it will then be replaced by an image. If 
2239     set-image-blocker (see below) also applies, the type of image will be
2240     determined by its parameter, if not, the standard checkerboard pattern is
2241     sent.
2242    
2243     It is important to understand this process, in order to understand how
2244     Privoxy deals with ads and other unwanted content.
2245    
2246     The filter action can perform a very similar task, by "blocking" banner
2247     images and other content through rewriting the relevant URLs in the
2248     document's HTML source, so they don't get requested in the first place.
2249     Note that this is a totally different technique, and it's easy to confuse
2250     the two.
2251    
2252 Example usage (section):
2253    
2254     {+block}      # Block and replace with "blocked" page              
2255     .nasty-stuff.example.com                                           
2256                                                                        
2257     {+block +handle-as-image} # Block and replace with image           
2258     .ad.doubleclick.net                                                
2259     .ads.r.us                                                          
2260    
2261 -------------------------------------------------------------------------------
2262
2263 8.5.3. crunch-incoming-cookies
2264
2265 Typical use:
2266    
2267     Prevent the web server from setting any cookies on your system
2268    
2269 Effect:
2270    
2271     Deletes any "Set-Cookie:" HTTP headers from server replies.
2272    
2273 Type:
2274    
2275     Boolean.
2276    
2277 Parameter:
2278    
2279     N/A
2280    
2281 Notes:
2282    
2283     This action is only concerned with incoming cookies. For outgoing cookies,
2284     use crunch-outgoing-cookies. Use both to disable cookies completely.
2285    
2286     It makes no sense at all to use this action in conjunction with the 
2287     session-cookies-only action, since it would prevent the session cookies
2288     from being set.
2289    
2290 Example usage:
2291    
2292     +crunch-incoming-cookies                                           
2293    
2294 -------------------------------------------------------------------------------
2295
2296 8.5.4. crunch-outgoing-cookies
2297
2298 Typical use:
2299    
2300     Prevent the web server from reading any cookies from your system
2301    
2302 Effect:
2303    
2304     Deletes any "Cookie:" HTTP headers from client requests.
2305    
2306 Type:
2307    
2308     Boolean.
2309    
2310 Parameter:
2311    
2312     N/A
2313    
2314 Notes:
2315    
2316     This action is only concerned with outgoing cookies. For incoming cookies,
2317     use crunch-incoming-cookies. Use both to disable cookies completely.
2318    
2319     It makes no sense at all to use this action in conjunction with the 
2320     session-cookies-only action, since it would prevent the session cookies
2321     from being read.
2322    
2323 Example usage:
2324    
2325     +crunch-outgoing-cookies                                           
2326    
2327 -------------------------------------------------------------------------------
2328
2329 8.5.5. deanimate-gifs
2330
2331 Typical use:
2332    
2333     Stop those annoying, distracting animated GIF images.
2334    
2335 Effect:
2336    
2337     De-animate GIF animations, i.e. reduce them to their first or last image.
2338    
2339 Type:
2340    
2341     Parameterized.
2342    
2343 Parameter:
2344    
2345     "last" or "first"
2346    
2347 Notes:
2348    
2349     This will also shrink the images considerably (in bytes, not pixels!). If
2350     the option "first" is given, the first frame of the animation is used as
2351     the replacement. If "last" is given, the last frame of the animation is
2352     used instead, which probably makes more sense for most banner animations,
2353     but also has the risk of not showing the entire last frame (if it is only a
2354     delta to an earlier frame).
2355    
2356     You can safely use this action with patterns that will also match non-GIF
2357     objects, because no attempt will be made at anything that doesn't look like
2358     a GIF.
2359    
2360 Example usage:
2361    
2362     +deanimate-gifs{last}                                              
2363    
2364 -------------------------------------------------------------------------------
2365
2366 8.5.6. downgrade-http-version
2367
2368 Typical use:
2369    
2370     Work around (very rare) problems with HTTP/1.1
2371    
2372 Effect:
2373    
2374     Downgrades HTTP/1.1 client requests and server replies to HTTP/1.0.
2375    
2376 Type:
2377    
2378     Boolean.
2379    
2380 Parameter:
2381    
2382     N/A
2383    
2384 Notes:
2385    
2386     This is a left-over from the time when Privoxy didn't support important
2387     HTTP/1.1 features well. It is left here for the unlikely case that you
2388     experience HTTP/1.1 related problems with some server out there. Not all
2389     (optional) HTTP/1.1 features are supported yet, so there is a chance you
2390     might need this action.
2391    
2392 Example usage (section):
2393    
2394     {+downgrade-http-version}                                          
2395     problem-host.example.com                                           
2396    
2397 -------------------------------------------------------------------------------
2398
2399 8.5.7. fast-redirects
2400
2401 Typical use:
2402    
2403     Fool some click-tracking scripts and speed up indirect links
2404    
2405 Effect:
2406    
2407     Cut off all but the last valid URL from requests.
2408    
2409 Type:
2410    
2411     Boolean.
2412    
2413 Parameter:
2414    
2415     N/A
2416    
2417 Notes:
2418    
2419     Many sites, like yahoo.com, don't just link to other sites. Instead, they
2420     will link to some script on their own servers, giving the destination as a
2421     parameter, which will then redirect you to the final target. URLs resulting
2422     from this scheme typically look like: http://some.place/click-tracker.cgi?
2423     target=http://some.where.else.
2424    
2425     Sometimes, there are even multiple consecutive redirects encoded in the
2426     URL. These redirections via scripts make your web browsing more traceable,
2427     since the server from which you follow such a link can see where you go to.
2428     Apart from that, valuable bandwidth and time is wasted, while your browser
2429     ask the server for one redirect after the other. Plus, it feeds the
2430     advertisers.
2431    
2432     This feature is currently not very smart and is scheduled for improvement.
2433     It is likely to break some sites. You should expect to need possibly many
2434     exceptions to this action, if it is enabled by default in default.action.
2435     Some sites just don't work without it.
2436    
2437 Example usage:
2438    
2439     {+fast-redirects}                                                  
2440    
2441 -------------------------------------------------------------------------------
2442
2443 8.5.8. filter
2444
2445 Typical use:
2446    
2447     Get rid of HTML and JavaScript annoyances, banner advertisements (by size),
2448     do fun text replacements, etc.
2449    
2450 Effect:
2451    
2452     Text documents, including HTML and JavaScript, to which this action
2453     applies, are filtered on-the-fly through the specified regular expression
2454     based substitutions.
2455    
2456 Type:
2457    
2458     Parameterized.
2459    
2460 Parameter:
2461    
2462     The name of a filter, as defined in the filter file (typically
2463     default.filter, set by the filterfile option in the config file). Filtering
2464     can be completely disabled without the use of parameters.
2465    
2466 Notes:
2467    
2468     For your convenience, there are a number of pre-defined filters available
2469     in the distribution filter file that you can use. See the examples below
2470     for a list.
2471    
2472     This is potentially a very powerful feature! But "rolling your own" filters
2473     requires a knowledge of regular expressions and HTML.
2474    
2475     Filtering requires buffering the page content, which may appear to slow
2476     down page rendering since nothing is displayed until all content has passed
2477     the filters. (It does not really take longer, but seems that way since the
2478     page is not incrementally displayed.) This effect will be more noticeable
2479     on slower connections.
2480    
2481     The amount of data that can be filtered is limited to the buffer-limit
2482     option in the main config file. The default is 4096 KB (4 Megs). Once this
2483     limit is exceeded, the buffered data, and all pending data, is passed
2484     through unfiltered. Inappropriate MIME types are not filtered.
2485    
2486     At this time, Privoxy cannot (yet!) uncompress compressed documents. If you
2487     want filtering to work on all documents, even those that would normally be
2488     sent compressed, use the prevent-compression action in conjunction with
2489     filter.
2490    
2491     Filtering can achieve some of the same effects as the block action, i.e. it
2492     can be used to block ads and banners. But the mechanism works quite
2493     differently. One effective use, is to block ad banners based on their size
2494     (see below), since many of these seem to be somewhat standardized.
2495    
2496     Feedback with suggestions for new or improved filters is particularly
2497     welcome!
2498    
2499 Example usage (with filters from the distribution default.filter file):
2500    
2501     +filter{html-annoyances}     # Get rid of particularly annoying HTML abuse.
2502    
2503     +filter{js-annoyances}       # Get rid of particularly annoying JavaScript abuse
2504    
2505     +filter{banners-by-size}     # Kill banners based on their size for this page (very efficient!)
2506    
2507     +filter{banners-by-link}     # Kill banners based on the link they are contained in (experimental)
2508    
2509     +filter{img-reorder}         # Reorder attributes in <img> tags to make the banners-by-* filters more effective
2510    
2511     +filter{content-cookies}     # Kill cookies that come sneaking in the HTML or JS content
2512    
2513     +filter{popups}              # Kill all popups in JS and HTML      
2514    
2515     +filter{webbugs}             # Squish WebBugs (1x1 invisible GIFs used for user tracking)
2516    
2517     +filter{fun}                 # Text replacements for subversive browsing fun!
2518    
2519     +filter{frameset-borders}    # Give frames a border and make them resizeable
2520    
2521     +filter{refresh-tags}        # Kill automatic refresh tags (for dial-on-demand setups)
2522    
2523     +filter{nimda}               # Remove Nimda (virus) code.          
2524    
2525     +filter{shockwave-flash}     # Kill embedded Shockwave Flash objects
2526    
2527     +filter{crude-parental}      # Kill all web pages that contain the words "sex" or "warez"
2528    
2529     +filter{js-events}           # Kill all JS event bindings (Radically destructive! Only for extra nasty sites) 
2530    
2531 -------------------------------------------------------------------------------
2532
2533 8.5.9. handle-as-image
2534
2535 Typical use:
2536    
2537     Mark URLs as belonging to images (so they'll be replaced by images if they
2538     get blocked)
2539    
2540 Effect:
2541    
2542     This action alone doesn't do anything noticeable. It just marks URLs as
2543     images. If the block action also applies, the presence or absence of this
2544     mark decides whether an HTML "blocked" page, or a replacement image (as
2545     determined by the set-image-blocker action) will be sent to the client as a
2546     substitute for the blocked content.
2547    
2548 Type:
2549    
2550     Boolean.
2551    
2552 Parameter:
2553    
2554     N/A
2555    
2556 Notes:
2557    
2558     The below generic example section is actually part of default.action. It
2559     marks all URLs with well-known image file name extensions as images and
2560     should be left intact.
2561    
2562     Users will probably only want to use the handle-as-image action in
2563     conjunction with block, to block sources of banners, whose URLs don't
2564     reflect the file type, like in the second example section.
2565    
2566     Note that you cannot treat HTML pages as images in most cases. For
2567     instance, (in-line) ad frames require an HTML page to be sent, or they
2568     won't display properly. Forcing handle-as-image in this situation will not
2569     replace the ad frame with an image, but lead to error messages.
2570    
2571 Example usage (sections):
2572    
2573     # Generic image extensions:                                        
2574     #                                                                  
2575     {+handle-as-image}                                                 
2576     /.*\.(gif|jpg|jpeg|png|bmp|ico)$                                   
2577                                                                        
2578     # These don't look like images, but they're banners and should be  
2579     # blocked as images:                                               
2580     #                                                                  
2581     {+block +handle-as-image}                                          
2582     some.nasty-banner-server.com/junk.cgi?output=trash                 
2583                                                                        
2584     # Banner source! Who cares if they also have non-image content?    
2585     ad.doubleclick.net                                                 
2586    
2587 -------------------------------------------------------------------------------
2588
2589 8.5.10. hide-forwarded-for-headers
2590
2591 Typical use:
2592    
2593     Improve privacy by hiding the true source of the request
2594    
2595 Effect:
2596    
2597     Deletes any existing "X-Forwarded-for:" HTTP header from client requests,
2598     and prevents adding a new one.
2599    
2600 Type:
2601    
2602     Boolean.
2603    
2604 Parameter:
2605    
2606     N/A
2607    
2608 Notes:
2609    
2610     It is fairly safe to leave this on.
2611    
2612     This action is scheduled for improvement: It should be able to generate
2613     forged "X-Forwarded-for:" headers using random IP addresses from a
2614     specified network, to make successive requests from the same client look
2615     like requests from a pool of different users sharing the same proxy.
2616    
2617 Example usage:
2618    
2619     +hide-forwarded-for-headers                                        
2620    
2621 -------------------------------------------------------------------------------
2622
2623 8.5.11. hide-from-header
2624
2625 Typical use:
2626    
2627     Keep your (old and ill) browser from telling web servers your email address
2628    
2629 Effect:
2630    
2631     Deletes any existing "From:" HTTP header, or replaces it with the specified
2632     string.
2633    
2634 Type:
2635    
2636     Parameterized.
2637    
2638 Parameter:
2639    
2640     Keyword: "block", or any user defined value.
2641    
2642 Notes:
2643    
2644     The keyword "block" will completely remove the header (not to be confused
2645     with the block action).
2646    
2647     Alternately, you can specify any value you prefer to be sent to the web
2648     server. If you do, it is a matter of fairness not to use any address that
2649     is actually used by a real person.
2650    
2651     This action is rarely needed, as modern web browsers don't send "From:"
2652     headers anymore.
2653    
2654 Example usage:
2655    
2656     +hide-from-header{block}                                           
2657    
2658     or
2659    
2660     +hide-from-header{spam-me-senseless@sittingduck.example.com}       
2661    
2662 -------------------------------------------------------------------------------
2663
2664 8.5.12. hide-referrer
2665
2666 Typical use:
2667    
2668     Conceal which link you followed to get to a particular site
2669    
2670 Effect:
2671    
2672     Deletes the "Referer:" (sic) HTTP header from the client request, or
2673     replaces it with a forged one.
2674    
2675 Type:
2676    
2677     Parameterized.
2678    
2679 Parameter:
2680    
2681       + "block" to delete the header completely.
2682        
2683       + "forge" to pretend to be coming from the homepage of the server we are
2684         talking to.
2685        
2686       + Any other string to set a user defined referrer.
2687        
2688 Notes:
2689    
2690     "forge" is the preferred option here, since some servers will not send
2691     images back otherwise, in an attempt to prevent their valuable content from
2692     being embedded elsewhere (and hence, without being surrounded by their
2693     banners).
2694    
2695     hide-referer is an alternate spelling of hide-referrer and the two can be
2696     can be freely substituted with each other. ("referrer" is the correct
2697     English spelling, however the HTTP specification has a bug - it requires it
2698     to be spelled as "referer".)
2699    
2700 Example usage:
2701    
2702     +hide-referrer{forge}                                              
2703    
2704     or
2705    
2706     +hide-referrer{http://www.yahoo.com/}                              
2707    
2708 -------------------------------------------------------------------------------
2709
2710 8.5.13. hide-user-agent
2711
2712 Typical use:
2713    
2714     Conceal your type of browser and client operating system
2715    
2716 Effect:
2717    
2718     Replaces the value of the "User-Agent:" HTTP header in client requests with
2719     the specified value.
2720    
2721 Type:
2722    
2723     Parameterized.
2724    
2725 Parameter:
2726    
2727     Any user-defined string.
2728    
2729 Notes:
2730    
2731     +-----------------------------------------------------------------+
2732     |                             Warning                             |
2733     |-----------------------------------------------------------------|
2734     |This breaks many web sites that depend on looking at this header |
2735     |in order to customize their content for different browsers       |
2736     |(which, by the way, is NOT a smart way to do that!).             |
2737     +-----------------------------------------------------------------+
2738    
2739     Using this action in multi-user setups or wherever different types of
2740     browsers will access the same Privoxy is not recommended. In single-user,
2741     single-browser setups, you might use it to delete your OS version
2742     information from the headers, because it is an invitation to exploit known
2743     bugs for your OS. It is also occasionally useful to forge this in order to
2744     access sites that won't let you in otherwise (though there may be a good
2745     reason in some cases). Example of this: some MSN sites will not let Mozilla
2746     enter, yet forging to a Netscape 6.1 user-agent works just fine. (Must be
2747     just a silly MS goof, I'm sure :-).
2748    
2749     This action is scheduled for improvement.
2750    
2751 Example usage:
2752    
2753     +hide-user-agent{Netscape 6.1 (X11; I; Linux 2.4.18 i686)}         
2754    
2755 -------------------------------------------------------------------------------
2756
2757 8.5.14. kill-popups
2758
2759 Typical use:
2760    
2761     Eliminate those annoying pop-up windows
2762    
2763 Effect:
2764    
2765     While loading the document, replace JavaScript code that opens pop-up
2766     windows with (syntactically neutral) dummy code on the fly.
2767    
2768 Type:
2769    
2770     Boolean.
2771    
2772 Parameter:
2773    
2774     N/A
2775    
2776 Notes:
2777    
2778     This action is easily confused with the built-in, hardwired filter action,
2779     but there are important differences: For kill-popups, the document need not
2780     be buffered, so it can be incrementally rendered while downloading. But
2781     kill-popups doesn't catch as many pop-ups as filter{popups} does.
2782    
2783     Think of it as a fast and efficient replacement for a filter that you can
2784     use if you don't want any filtering at all. Note that it doesn't make sense
2785     to combine it with any filter action, since as soon as one filter applies,
2786     the whole document needs to be buffered anyway, which destroys the
2787     advantage of the kill-popups action over its filter equivalent.
2788    
2789     Killing all pop-ups is a dangerous business. Many shops and banks rely on
2790     pop-ups to display forms, shopping carts etc, and killing only the unwanted
2791     pop-ups would require artificial intelligence in Privoxy. If the only kind
2792     of pop-ups that you want to kill are exit consoles (those really nasty
2793     windows that appear when you close an other one), you might want to use 
2794     filter{js-annoyances} instead.
2795    
2796 Example usage:
2797    
2798     +kill-popups                                                       
2799    
2800 -------------------------------------------------------------------------------
2801
2802 8.5.15. limit-connect
2803
2804 Typical use:
2805    
2806     Prevent abuse of Privoxy as a TCP proxy relay
2807    
2808 Effect:
2809    
2810     Specifies to which ports HTTP CONNECT requests are allowable.
2811    
2812 Type:
2813    
2814     Parameterized.
2815    
2816 Parameter:
2817    
2818     A comma-separated list of ports or port ranges (the latter using dashes,
2819     with the minimum defaulting to 0 and the maximum to 65K).
2820    
2821 Notes:
2822    
2823     By default, i.e. if no limit-connect action applies, Privoxy only allows
2824     HTTP CONNECT requests to port 443 (the standard, secure HTTPS port). Use
2825     limit-connect if more fine-grained control is desired for some or all
2826     destinations.
2827    
2828     The CONNECT methods exists in HTTP to allow access to secure websites
2829     ("https://" URLs) through proxies. It works very simply: the proxy connects
2830     to the server on the specified port, and then short-circuits its
2831     connections to the client and to the remote server. This can be a big
2832     security hole, since CONNECT-enabled proxies can be abused as TCP relays
2833     very easily.
2834    
2835     If you don't know what any of this means, there probably is no reason to
2836     change this one, since the default is already very restrictive.
2837    
2838 Example usages:
2839    
2840     +limit-connect{443}                   # This is the default and need not be specified.        
2841     +limit-connect{80,443}                # Ports 80 and 443 are OK.                              
2842     +limit-connect{-3, 7, 20-100, 500-}   # Ports less than 3, 7, 20 to 100 and above 500 are OK. 
2843     +limit-connect{-}                     # All ports are OK (gaping security hole!)              
2844    
2845 -------------------------------------------------------------------------------
2846
2847 8.5.16. prevent-compression
2848
2849 Typical use:
2850    
2851     Ensure that servers send the content uncompressed, so it can be passed
2852     through filters
2853    
2854 Effect:
2855    
2856     Adds a header to the request that asks for uncompressed transfer.
2857    
2858 Type:
2859    
2860     Boolean.
2861    
2862 Parameter:
2863    
2864     N/A
2865    
2866 Notes:
2867    
2868     More and more websites send their content compressed by default, which is
2869     generally a good idea and saves bandwidth. But for the filter, 
2870     deanimate-gifs and kill-popups actions to work, Privoxy needs access to the
2871     uncompressed data. Unfortunately, Privoxy can't yet(!) uncompress, filter,
2872     and re-compress the content on the fly. So if you want to ensure that all
2873     websites, including those that normally compress, can be filtered, you need
2874     to use this action.
2875    
2876     This will slow down transfers from those websites, though. If you use any
2877     of the above-mentioned actions, you will typically want to use
2878     prevent-compression in conjunction with them.
2879    
2880     Note that some (rare) ill-configured sites don't handle requests for
2881     uncompressed documents correctly (they send an empty document body). If you
2882     use prevent-compression per default, you'll have to add exceptions for
2883     those sites. See the example for how to do that.
2884    
2885 Example usage (sections):
2886    
2887     # Set default:                                                     
2888     #                                                                  
2889     {+prevent-compression}                                             
2890     / # Match all sites                                                
2891                                                                        
2892     # Make exceptions for ill sites:                                   
2893     #                                                                  
2894     {-prevent-compression}                                             
2895     www.debianhelp.org                                                 
2896     www.pclinuxonline.com                                              
2897    
2898 -------------------------------------------------------------------------------
2899
2900 8.5.17. send-vanilla-wafer
2901
2902 Typical use:
2903    
2904     Feed log analysis scripts with useless data.
2905    
2906 Effect:
2907    
2908     Sends a cookie with each request stating that you do not accept any
2909     copyright on cookies sent to you, and asking the site operator not to track
2910     you.
2911    
2912 Type:
2913    
2914     Boolean.
2915    
2916 Parameter:
2917    
2918     N/A
2919    
2920 Notes:
2921    
2922     The vanilla wafer is a (relatively) unique header and could conceivably be
2923     used to track you.
2924    
2925     This action is rarely used and not enabled in the default configuration.
2926    
2927 Example usage:
2928    
2929     +send-vanilla-wafer                                                
2930    
2931 -------------------------------------------------------------------------------
2932
2933 8.5.18. send-wafer
2934
2935 Typical use:
2936    
2937     Send custom cookies or feed log analysis scripts with even more useless
2938     data.
2939    
2940 Effect:
2941    
2942     Sends a custom, user-defined cookie with each request.
2943    
2944 Type:
2945    
2946     Multi-value.
2947    
2948 Parameter:
2949    
2950     A string of the form "name=value".
2951    
2952 Notes:
2953    
2954     Being multi-valued, multiple instances of this action can apply to the same
2955     request, resulting in multiple cookies being sent.
2956    
2957     This action is rarely used and not enabled in the default configuration.
2958    
2959 Example usage (section):
2960    
2961     {+send-wafer{UsingPrivoxy=true}}                                   
2962     my-internal-testing-server.void                                    
2963    
2964 -------------------------------------------------------------------------------
2965
2966 8.5.19. session-cookies-only
2967
2968 Typical use:
2969    
2970     Allow only temporary "session" cookies (for the current browser session
2971     only).
2972    
2973 Effect:
2974    
2975     Deletes the "expires" field from "Set-Cookie:" server headers. Most
2976     browsers will not store such cookies permanently and forget them in between
2977     sessions.
2978    
2979 Type:
2980    
2981     Boolean.
2982    
2983 Parameter:
2984    
2985     N/A
2986    
2987 Notes:
2988    
2989     This is less strict than crunch-incoming-cookies / crunch-outgoing-cookies
2990     and allows you to browse websites that insist or rely on setting cookies,
2991     without compromising your privacy too badly.
2992    
2993     Most browsers will not permanently store cookies that have been processed
2994     by session-cookies-only and will forget about them between sessions. This
2995     makes profiling cookies useless, but won't break sites which require
2996     cookies so that you can log in for transactions. This is generally turned
2997     on for all sites, and is the recommended setting.
2998    
2999     It makes no sense at all to use session-cookies-only together with 
3000     crunch-incoming-cookies or crunch-outgoing-cookies. If you do, cookies will
3001     be plainly killed.
3002    
3003     Note that it is up to the browser how it handles such cookies without an
3004     "expires" field. If you use an exotic browser, you might want to try it out
3005     to be sure.
3006    
3007 Example usage:
3008    
3009     +session-cookies-only                                              
3010    
3011 -------------------------------------------------------------------------------
3012
3013 8.5.20. set-image-blocker
3014
3015 Typical use:
3016    
3017     Choose the replacement for blocked images
3018    
3019 Effect:
3020    
3021     This action alone doesn't do anything noticeable. If both block and 
3022     handle-as-image also apply, i.e. if the request is to be blocked as an
3023     image, then the parameter of this action decides what will be sent as a
3024     replacement.
3025    
3026 Type:
3027    
3028     Parameterized.
3029    
3030 Parameter:
3031    
3032       + "pattern" to send a built-in checkerboard pattern image. The image is
3033         visually decent, scales very well, and makes it obvious where banners
3034         were busted.
3035        
3036       + "blank" to send a built-in transparent image. This makes banners
3037         disappear completely, but makes it hard to detect where Privoxy has
3038         blocked images on a given page and complicates troubleshooting if
3039         Privoxy has blocked innocent images, like navigation icons.
3040        
3041       + "target-url" to send a redirect to target-url. You can redirect to any
3042         image anywhere, even in your local filesystem (via "file:///" URL).
3043        
3044         A good application of redirects is to use special Privoxy-built-in
3045         URLs, which send the built-in images, as target-url. This has the same
3046         visual effect as specifying "blank" or "pattern" in the first place,
3047         but enables your browser to cache the replacement image, instead of
3048         requesting it over and over again.
3049        
3050 Notes:
3051    
3052     The URLs for the built-in images are "http://config.privoxy.org/
3053     send-banner?type=type", where type is either "blank" or "pattern".
3054    
3055     There is a third (advanced) type, called "auto". It is NOT to be used in
3056     set-image-blocker, but meant for use from filters. Auto will select the
3057     type of image that would have applied to the referring page, had it been an
3058     image.
3059    
3060 Example usage:
3061    
3062     Built-in pattern:
3063    
3064     +set-image-blocker{pattern}                                        
3065    
3066     Redirect to the BSD devil:
3067    
3068     +set-image-blocker{http://www.freebsd.org/gifs/dae_up3.gif}        
3069    
3070     Redirect to the built-in pattern for better caching:
3071    
3072     +set-image-blocker{http://config.privoxy.org/send-banner?type=pattern}
3073    
3074 -------------------------------------------------------------------------------
3075
3076 8.5.21. Summary
3077
3078 Note that many of these actions have the potential to cause a page to
3079 misbehave, possibly even not to display at all. There are many ways a site
3080 designer may choose to design his site, and what HTTP header content, and other
3081 criteria, he may depend on. There is no way to have hard and fast rules for all
3082 sites. See the Appendix for a brief example on troubleshooting actions.
3083
3084 -------------------------------------------------------------------------------
3085
3086 8.6. Aliases
3087
3088 Custom "actions", known to Privoxy as "aliases", can be defined by combining
3089 other actions. These can in turn be invoked just like the built-in actions.
3090 Currently, an alias name can contain any character except space, tab, "=", "{"
3091 and "}", but we strongly recommend that you only use "a" to "z", "0" to "9",
3092 "+", and "-". Alias names are not case sensitive, and are not required to start
3093 with a "+" or "-" sign, since they are merely textually expanded.
3094
3095 Aliases can be used throughout the actions file, but they must be defined in a
3096 special section at the top of the file! And there can only be one such section
3097 per actions file. Each actions file may have its own alias section, and the
3098 aliases defined in it are only visible within that file.
3099
3100 There are two main reasons to use aliases: One is to save typing for frequently
3101 used combinations of actions, the other one is a gain in flexibility: If you
3102 decide once how you want to handle shops by defining an alias called "shop",
3103 you can later change your policy on shops in one place, and your changes will
3104 take effect everywhere in the actions file where the "shop" alias is used.
3105 Calling aliases by their purpose also makes your actions files more readable.
3106
3107 Currently, there is one big drawback to using aliases, though: Privoxy's
3108 built-in web-based action file editor honors aliases when reading the actions
3109 files, but it expands them before writing. So the effects of your aliases are
3110 of course preserved, but the aliases themselves are lost when you edit sections
3111 that use aliases with it. This is likely to change in future versions of
3112 Privoxy.
3113
3114 Now let's define some aliases...
3115
3116  # Useful custom aliases we can use later.                                                   
3117  #                                                                                           
3118  # Note the (required!) section header line and that this section                            
3119  # must be at the top of the actions file!                                                   
3120  #                                                                                           
3121  {{alias}}                                                                                   
3122                                                                                              
3123  # These aliases just save typing later:                                                     
3124  # (Note that some already use other aliases!)                                               
3125  #                                                                                           
3126  +crunch-all-cookies = +crunch-incoming-cookies +crunch-outgoing-cookies                     
3127  -crunch-all-cookies = -crunch-incoming-cookies -crunch-outgoing-cookies                     
3128  block-as-image      = +block +handle-as-image                                               
3129  mercy-for-cookies   = -crunch-all-cookies -session-cookies-only                             
3130                                                                                              
3131  # These aliases define combinations of actions                                              
3132  # that are useful for certain types of sites:                                               
3133  #                                                                                           
3134  fragile     = -block -crunch-all-cookies -filter -fast-redirects -hide-referer -kill-popups 
3135  shop        = -crunch-all-cookies -filter{popups} -kill-popups                              
3136                                                                                              
3137  # Short names for other aliases, for really lazy people ;-)                                 
3138  #                                                                                           
3139  c0 = +crunch-all-cookies                                                                    
3140  c1 = -crunch-all-cookies                                                                    
3141
3142 ...and put them to use. These sections would appear in the lower part of an
3143 actions file and define exceptions to the default actions (as specified further
3144 up for the "/" pattern):
3145
3146  # These sites are either very complex or very keen on                         
3147  # user data and require minimal interference to work:                         
3148  #                                                                             
3149  {fragile}                                                                     
3150  .office.microsoft.com                                                         
3151  .windowsupdate.microsoft.com                                                  
3152  .nytimes.com                                                                  
3153                                                                                
3154  # Shopping sites:                                                             
3155  # Allow cookies (for setting and retrieving your customer data)               
3156  #                                                                             
3157  {shop}                                                                        
3158  .quietpc.com                                                                  
3159  .worldpay.com   # for quietpc.com                                             
3160  .scan.co.uk                                                                   
3161                                                                                
3162  # These shops require pop-ups:                                                
3163  #                                                                             
3164  {shop -kill-popups -filter{popups}}                                           
3165   .dabs.com                                                                    
3166   .overclockers.co.uk                                                          
3167
3168 Aliases like "shop" and "fragile" are often used for "problem" sites that
3169 require some actions to be disabled in order to function properly.
3170
3171 -------------------------------------------------------------------------------
3172
3173 8.7. Actions Files Tutorial
3174
3175 The above chapters have shown which actions files there are and how they are
3176 organized, how actions are specified and applied to URLs, how patterns work,
3177 and how to define and use aliases. Now, let's look at an example default.action
3178 and user.action file and see how all these pieces come together:
3179
3180 -------------------------------------------------------------------------------
3181
3182 8.7.1. default.action
3183
3184 Every config file should start with a short comment stating its purpose:
3185
3186 # Sample default.action file <developers@privoxy.org>                          
3187
3188 Then, since this is the default.action file, the first section is a special
3189 section for internal use that you needn't change or worry about:
3190
3191 ##########################################################################     
3192 # Settings -- Don't change! For internal Privoxy use ONLY.                     
3193 ##########################################################################     
3194                                                                                
3195 {{settings}}                                                                   
3196 for-privoxy-version=3.0                                                        
3197
3198 After that comes the (optional) alias section. We'll use the example section
3199 from the above chapter on aliases, that also explains why and how aliases are
3200 used:
3201
3202 ##########################################################################                  
3203 # Aliases                                                                                   
3204 ##########################################################################                  
3205 {{alias}}                                                                                   
3206                                                                                             
3207 # These aliases just save typing later:                                                     
3208 # (Note that some already use other aliases!)                                               
3209 #                                                                                           
3210 +crunch-all-cookies = +crunch-incoming-cookies +crunch-outgoing-cookies                     
3211 -crunch-all-cookies = -crunch-incoming-cookies -crunch-outgoing-cookies                     
3212 block-as-image      = +block +handle-as-image                                               
3213 mercy-for-cookies   = -crunch-all-cookies -session-cookies-only                             
3214                                                                                             
3215 # These aliases define combinations of actions                                              
3216 # that are useful for certain types of sites:                                               
3217 #                                                                                           
3218 fragile     = -block -crunch-all-cookies -filter -fast-redirects -hide-referer -kill-popups 
3219 shop        = mercy-for-cookies -filter{popups} -kill-popups                                
3220
3221 Now come the regular sections, i.e. sets of actions, accompanied by URL
3222 patterns to which they apply. Remember all actions are disabled when matching
3223 starts, so we have to explicitly enable the ones we want.
3224
3225 The first regular section is probably the most important. It has only one
3226 pattern, "/", but this pattern matches all URLs. Therefore, the set of actions
3227 used in this "default" section will be applied to all requests as a start. It
3228 can be partly or wholly overridden by later matches further down this file, or
3229 in user.action, but it will still be largely responsible for your overall
3230 browsing experience.
3231
3232 Again, at the start of matching, all actions are disabled, so there is no real
3233 need to disable any actions here, but we will do that nonetheless, to have a
3234 complete listing for your reference. (Remember: a "+" preceding the action name
3235 enables the action, a "-" disables!). Also note how this long line has been
3236 made more readable by splitting it into multiple lines with line continuation.
3237
3238 ##########################################################################     
3239 # "Defaults" section:                                                          
3240 ##########################################################################     
3241  { \                                                                           
3242  -add-header \                                                                 
3243  -block \                                                                      
3244  -crunch-incoming-cookies \                                                    
3245  -crunch-outgoing-cookies \                                                    
3246  +deanimate-gifs \                                                             
3247  -downgrade-http-version \                                                     
3248  +fast-redirects \                                                             
3249  +filter{html-annoyances} \                                                    
3250  +filter{js-annoyances} \                                                      
3251  -filter{content-cookies} \                                                    
3252  +filter{popups} \                                                             
3253  +filter{webbugs} \                                                            
3254  -filter{refresh-tags} \                                                       
3255  -filter{fun} \                                                                
3256  +filter{nimda} \                                                              
3257  +filter{banners-by-size} \                                                    
3258  -filter{banners-by-link} \                                                    
3259  -filter{img-reorder} \                                                        
3260  -filter{shockwave-flash} \                                                    
3261  -filter{crude-parental} \                                                     
3262  -filter{js-events} \                                                          
3263  -handle-as-image \                                                            
3264  +hide-forwarded-for-headers \                                                 
3265  +hide-from-header{block} \                                                    
3266  +hide-referrer{forge} \                                                       
3267  -hide-user-agent \                                                            
3268  -kill-popups \                                                                
3269  -limit-connect \                                                              
3270  +prevent-compression \                                                        
3271  -send-vanilla-wafer \                                                         
3272  -send-wafer \                                                                 
3273  +session-cookies-only \                                                       
3274  +set-image-blocker{pattern} \                                                 
3275  }                                                                             
3276  / # forward slash will match *all* potential URL patterns.                    
3277
3278 The default behavior is now set. Note that some actions, like not hiding the
3279 user agent, are part of a "general policy" that applies universally and won't
3280 get any exceptions defined later. Other choices, like not blocking (which is
3281 understandably the default!) need exceptions, i.e. we need to specify
3282 explicitly what we want to block in later sections. We will also want to make
3283 exceptions from our general pop-up-killing, and use our defined aliases for
3284 that.
3285
3286 The first of our specialized sections is concerned with "fragile" sites, i.e.
3287 sites that require minimum interference, because they are either very complex
3288 or very keen on tracking you (and have mechanisms in place that make them
3289 unusable for people who avoid being tracked). We will simply use our
3290 pre-defined fragile alias instead of stating the list of actions explicitly:
3291
3292 ##########################################################################     
3293 # Exceptions for sites that'll break under the default action set:             
3294 ##########################################################################     
3295                                                                                
3296 # "Fragile" Use a minimum set of actions for these sites (see alias above):    
3297 #                                                                              
3298 { fragile }                                                                    
3299 .office.microsoft.com           # surprise, surprise!                          
3300 .windowsupdate.microsoft.com                                                   
3301
3302 Shopping sites are not as fragile, but they typically require cookies to log
3303 in, and pop-up windows for shopping carts or item details. Again, we'll use a
3304 pre-defined alias:
3305
3306 # Shopping sites:                                                              
3307 #                                                                              
3308 { shop }                                                                       
3309 .quietpc.com                                                                   
3310 .worldpay.com   # for quietpc.com                                              
3311 .jungle.com                                                                    
3312 .scan.co.uk                                                                    
3313
3314 Then, there are sites which rely on pop-up windows (yuck!) to work. Since we
3315 made pop-up-killing our default above, we need to make exceptions now. Mozilla
3316 users, who can turn on smart handling of unwanted pop-ups in their browsers,
3317 can safely choose -filter{popups} (and -kill-popups) above and hence don't need
3318 this section. Anyway, disabling an already disabled action doesn't hurt, so
3319 we'll define our exceptions regardless of what was chosen in the defaults
3320 section:
3321
3322 # These sites require pop-ups too :(                                           
3323 #                                                                              
3324 { -kill-popups -filter{popups} }                                               
3325 .dabs.com                                                                      
3326 .overclockers.co.uk                                                            
3327 .deutsche-bank-24.de                                                           
3328
3329 The fast-redirects action, which we enabled per default above, breaks some
3330 sites. So disable it for popular sites where we know it misbehaves:
3331
3332 { -fast-redirects }                                                            
3333 login.yahoo.com                                                                
3334 edit.*.yahoo.com                                                               
3335 .google.com                                                                    
3336 .altavista.com/.*(like|url|link):http                                          
3337 .altavista.com/trans.*urltext=http                                             
3338 .nytimes.com                                                                   
3339
3340 It is important that Privoxy knows which URLs belong to images, so that if they
3341 are to be blocked, a substitute image can be sent, rather than an HTML page.
3342 Contacting the remote site to find out is not an option, since it would destroy
3343 the loading time advantage of banner blocking, and it would feed the
3344 advertisers (in terms of money and information). We can mark any URL as an
3345 image with the handle-as-image action, and marking all URLs that end in a known
3346 image file extension is a good start:
3347
3348 ##########################################################################     
3349 # Images:                                                                      
3350 ##########################################################################     
3351                                                                                
3352 # Define which file types will be treated as images, in case they get          
3353 # blocked further down this file:                                              
3354 #                                                                              
3355 { +handle-as-image }                                                           
3356 /.*\.(gif|jpe?g|png|bmp|ico)$                                                  
3357
3358 And then there are known banner sources. They often use scripts to generate the
3359 banners, so it won't be visible from the URL that the request is for an image.
3360 Hence we block them and mark them as images in one go, with the help of our
3361 block-as-image alias defined above. (We could of course just as well use +block
3362 +handle-as-image here.) Remember that the type of the replacement image is
3363 chosen by the set-image-blocker action. Since all URLs have matched the default
3364 section with its +set-image-blocker{pattern} action before, it still applies
3365 and needn't be repeated:
3366
3367 # Known ad generators:                                                         
3368 #                                                                              
3369 { block-as-image }                                                             
3370 ar.atwola.com                                                                  
3371 .ad.doubleclick.net                                                            
3372 .ad.*.doubleclick.net                                                          
3373 .a.yimg.com/(?:(?!/i/).)*$                                                     
3374 .a[0-9].yimg.com/(?:(?!/i/).)*$                                                
3375 bs*.gsanet.com                                                                 
3376 bs*.einets.com                                                                 
3377 .qkimg.net                                                                     
3378
3379 One of the most important jobs of Privoxy is to block banners. A huge bunch of
3380 them are already "blocked" by the filter{banners-by-size} action, which we
3381 enabled above, and which deletes the references to banner images from the pages
3382 while they are loaded, so the browser doesn't request them anymore, and hence
3383 they don't need to be blocked here. But this naturally doesn't catch all
3384 banners, and some people choose not to use filters, so we need a comprehensive
3385 list of patterns for banner URLs here, and apply the block action to them.
3386
3387 First comes a bunch of generic patterns, which do most of the work, by matching
3388 typical domain and path name components of banners. Then comes a list of
3389 individual patterns for specific sites, which is omitted here to keep the
3390 example short:
3391
3392 ##########################################################################     
3393 # Block these fine banners:                                                    
3394 ##########################################################################     
3395 { +block }                                                                     
3396                                                                                
3397 # Generic patterns:                                                            
3398 #                                                                              
3399 ad*.                                                                           
3400 .*ads.                                                                         
3401 banner?.                                                                       
3402 count*.                                                                        
3403 /.*count(er)?\.(pl|cgi|exe|dll|asp|php[34]?)                                   
3404 /(?:.*/)?(publicite|werbung|rekla(ma|me|am)|annonse|maino(kset|nta|s)?)/       
3405                                                                                
3406 # Site-specific patterns (abbreviated):                                        
3407 #                                                                              
3408 .hitbox.com                                                                    
3409
3410 You wouldn't believe how many advertisers actually call their banner servers
3411 ads.company.com, or call the directory in which the banners are stored simply
3412 "banners". So the above generic patterns are surprisingly effective.
3413
3414 But being very generic, they necessarily also catch URLs that we don't want to
3415 block. The pattern .*ads. e.g. catches "nasty-ads.nasty-corp.com" as intended,
3416 but also "downloads.sourcefroge.net" or "adsl.some-provider.net." So here come
3417 some well-known exceptions to the +block section above.
3418
3419 Note that these are exceptions to exceptions from the default! Consider the URL
3420 "downloads.sourcefroge.net": Initially, all actions are deactivated, so it
3421 wouldn't get blocked. Then comes the defaults section, which matches the URL,
3422 but just deactivates the block action once again. Then it matches .*ads., an
3423 exception to the general non-blocking policy, and suddenly +block applies. And
3424 now, it'll match .*loads., where -block applies, so (unless it matches again
3425 further down) it ends up with no block action applying.
3426
3427 ##########################################################################     
3428 # Save some innocent victims of the above generic block patterns:              
3429 ##########################################################################     
3430                                                                                
3431 # By domain:                                                                   
3432 #                                                                              
3433 { -block }                                                                     
3434 adv[io]*.  # (for advogato.org and advice.*)                                   
3435 adsl.      # (has nothing to do with ads)                                      
3436 ad[ud]*.   # (adult.* and add.*)                                               
3437 .edu       # (universities don't host banners (yet!))                          
3438 .*loads.   # (downloads, uploads etc)                                          
3439                                                                                
3440 # By path:                                                                     
3441 #                                                                              
3442 /.*loads/                                                                      
3443                                                                                
3444 # Site-specific:                                                               
3445 #                                                                              
3446 www.globalintersec.com/adv # (adv = advanced)                                  
3447 www.ugu.com/sui/ugu/adv                                                        
3448
3449 Filtering source code can have nasty side effects, so make an exception for our
3450 friends at sourceforge.net, and all paths with "cvs" in them. Note that -filter
3451 disables all filters in one fell swoop!
3452
3453 # Don't filter code!                                                           
3454 #                                                                              
3455 { -filter }                                                                    
3456 /.*cvs                                                                         
3457 .sourceforge.net                                                               
3458
3459 The actual default.action is of course more comprehensive, but we hope this
3460 example made clear how it works.
3461
3462 -------------------------------------------------------------------------------
3463
3464 8.7.2. user.action
3465
3466 So far we are painting with a broad brush by setting general policies, which
3467 would be a reasonable starting point for many people. Now, you might want to be
3468 more specific and have customized rules that are more suitable to your personal
3469 habits and preferences. These would be for narrowly defined situations like
3470 your ISP or your bank, and should be placed in user.action, which is parsed
3471 after all other actions files and hence has the last word, over-riding any
3472 previously defined actions. user.action is also a safe place for your personal
3473 settings, since default.action is actively maintained by the Privoxy developers
3474 and you'll probably want to install updated versions from time to time.
3475
3476 So let's look at a few examples of things that one might typically do in
3477 user.action:
3478
3479 # My user.action file. <fred@foobar.com>                                       
3480
3481 As aliases are local to the actions file that they are defined in, you can't
3482 use the ones from default.action, unless you repeat them here:
3483
3484 # (Re-)define aliases for this file:                                                        
3485 #                                                                                           
3486 {{alias}}                                                                                   
3487 -crunch-all-cookies = -crunch-incoming-cookies -crunch-outgoing-cookies                     
3488 mercy-for-cookies   = -crunch-all-cookies -session-cookies-only                             
3489 fragile     = -block -crunch-all-cookies -filter -fast-redirects -hide-referer -kill-popups 
3490 shop        = mercy-for-cookies -filter{popups} -kill-popups                                
3491 allow-ads   = -block -filter{banners-by-size} # (see below)                                 
3492
3493 Say you have accounts on some sites that you visit regularly, and you don't
3494 want to have to log in manually each time. So you'd like to allow persistent
3495 cookies for these sites. The mercy-for-cookies alias defined above does exactly
3496 that, i.e. it disables crunching of cookies in any direction, and processing of
3497 cookies to make them temporary.
3498
3499 { mercy-for-cookies }                                                          
3500 sunsolve.sun.com                                                               
3501 slashdot.org                                                                   
3502 .yahoo.com                                                                     
3503 .msdn.microsoft.com                                                            
3504 .redhat.com                                                                    
3505
3506 Your bank needs popups and is allergic to some filter, but you don't know
3507 which, so you disable them all:
3508
3509 { -filter -kill-popups }                                                       
3510 .your-home-banking-site.com                                                    
3511
3512 While browsing the web with Privoxy you noticed some ads that sneaked through,
3513 but you were too lazy to report them through our fine and easy feedback system,
3514 so you have added them here:
3515
3516 { +block }                                                                     
3517 www.a-popular-site.com/some/unobvious/path                                     
3518 another.popular.site.net/more/junk/here/                                       
3519
3520 Note that, assuming the banners in the above example have regular image
3521 extensions (most do), +handle-as-image need not be specified, since all URLs
3522 ending in these extensions will already have been tagged as images in the
3523 relevant section of default.action by now.
3524
3525 Then you noticed that the default configuration breaks Forbes Magazine, but you
3526 were too lazy to find out which action is the culprit, and you were again too
3527 lazy to give feedback, so you just used the fragile alias on the site, and --
3528 whoa! -- it worked:
3529
3530 { fragile }                                                                    
3531 .forbes.com                                                                    
3532
3533 You like the "fun" text replacements in default.filter, but it is disabled in
3534 the distributed actions file. (My colleagues on the team just don't have a
3535 sense of humour, that's why! ;-). So you'd like to turn it on in your private,
3536 update-safe config, once and for all:
3537
3538 { +filter{fun} }                                                               
3539 / # For ALL sites!                                                             
3540
3541 Note that the above is not really a good idea: There are exceptions to the
3542 filters in default.action for things that really shouldn't be filtered, like
3543 code on CVS->Web interfaces. Since user.action has the last word, these
3544 exceptions won't be valid for the "fun" filtering specified here.
3545
3546 Finally, you might think about how your favourite free websites are funded, and
3547 find that they rely on displaying banner advertisements to survive. So you
3548 might want to specifically allow banners for those sites that you feel provide
3549 value to you:
3550
3551 { allow-ads }                                                                  
3552 .sourceforge.net                                                               
3553 .slashdot.org                                                                  
3554 .osdn.net                                                                      
3555
3556 Note that allow-ads has been aliased to -block -filter{banners-by-size} above.
3557
3558 -------------------------------------------------------------------------------
3559
3560 9. The Filter File
3561
3562 All text substitutions that can be invoked through the filter action must first
3563 be defined in the filter file, which is typically called default.filter and
3564 which can be selected through the filterfile config option.
3565
3566 Typical reasons for doing such substitutions are to eliminate common annoyances
3567 in HTML and JavaScript, such as pop-up windows, exit consoles, crippled windows
3568 without navigation tools, the infamous <BLINK> tag etc, to suppress images with
3569 certain width and height attributes (standard banner sizes or web-bugs), or
3570 just to have fun. The possibilities are endless.
3571
3572 Filtering works on any text-based document type, including plain text, HTML,
3573 JavaScript, CSS etc. (all text/* MIME types). Substitutions are made at the
3574 source level, so if you want to "roll your own" filters, you should be familiar
3575 with HTML syntax.
3576
3577 Just like the actions files, the filter file is organized in sections, which
3578 are called filters here. Each filter consists of a heading line, that starts
3579 with the keyword FILTER:, followed by the filter's name, and a short (one line)
3580 description of what it does. Below that line come the jobs, i.e. lines that
3581 define the actual text substitutions. By convention, the name of a filter
3582 should describe what the filter eliminates. The comment is used in the 
3583 web-based user interface.
3584
3585 Once a filter called name has been defined in the filter file, it can be
3586 invoked by using an action of the form +filter{name} in any actions file.
3587
3588 A filter header line for a filter called "foo" could look like this:
3589
3590 FILTER: foo Replace all "foo" with "bar"                                       
3591
3592 Below that line, and up to the next header line, come the jobs that define what
3593 text replacements the filter executes. They are specified in a syntax that
3594 imitates Perl's s/// operator. If you are familiar with Perl, you will find
3595 this to be quite intuitive, and may want to look at the PCRS man page for the
3596 subtle differences to Perl behaviour. Most notably, the non-standard option
3597 letter U is supported, which turns the default to ungreedy matching.
3598
3599 If you are new to regular expressions, you might want to take a look at the 
3600 Appendix on regular expressions, and see the Perl manual for the s///
3601 operator's syntax and Perl-style regular expressions in general. The below
3602 examples might also help to get you started.
3603
3604 -------------------------------------------------------------------------------
3605
3606 9.1. Filter File Tutorial
3607
3608 Now, let's complete our "foo" filter. We have already defined the heading, but
3609 the jobs are still missing. Since all it does is to replace "foo" with "bar",
3610 there is only one (trivial) job needed:
3611
3612 s/foo/bar/                                                                     
3613
3614 But wait! Didn't the comment say that all occurrences of "foo" should be
3615 replaced? Our current job will only take care of the first "foo" on each page.
3616 For global substitution, we'll need to add the g option:
3617
3618 s/foo/bar/g                                                                    
3619
3620 Our complete filter now looks like this:
3621
3622 FILTER: foo Replace all "foo" with "bar"                                       
3623 s/foo/bar/g                                                                    
3624
3625 Let's look at some real filters for more interesting examples. Here you see a
3626 filter that protects against some common annoyances that arise from JavaScript
3627 abuse. Let's look at its jobs one after the other:
3628
3629 FILTER: js-annoyances Get rid of particularly annoying JavaScript abuse                         
3630                                                                                                 
3631 # Get rid of JavaScript referrer tracking. Test page: http://www.randomoddness.com/untitled.htm 
3632 #                                                                                               
3633 s|(<script.*)document\.referrer(.*</script>)|$1"Not Your Business!"$2|Usg                       
3634
3635 Following the header line and a comment, you see the job. Note that it uses |
3636 as the delimiter instead of /, because the pattern contains a forward slash,
3637 which would otherwise have to be escaped by a backslash (\).
3638
3639 Now, let's examine the pattern: it starts with the text <script.* enclosed in
3640 parentheses. Since the dot matches any character, and * means: "Match an
3641 arbitrary number of the element left of myself", this matches "<script",
3642 followed by any text, i.e. it matches the whole page, from the start of the
3643 first <script> tag.
3644
3645 That's more than we want, but the pattern continues: document\.referrer matches
3646 only the exact string "document.referrer". The dot needed to be escaped, i.e.
3647 preceded by a backslash, to take away its special meaning as a joker, and make
3648 it just a regular dot. So far, the meaning is: Match from the start of the
3649 first <script> tag in a the page, up to, and including, the text
3650 "document.referrer", if both are present in the page (and appear in that
3651 order).
3652
3653 But there's still more pattern to go. The next element, again enclosed in
3654 parentheses, is .*</script>. You already know what .* means, so the whole
3655 pattern translates to: Match from the start of the first <script> tag in a page
3656 to the end of the last <script> tag, provided that the text "document.referrer"
3657 appears somewhere in between.
3658
3659 This is still not the whole story, since we have ignored the options and the
3660 parentheses: The portions of the page matched by sub-patterns that are enclosed
3661 in parentheses, will be remembered and be available through the variables $1,
3662 $2, ... in the substitute. The U option switches to ungreedy matching, which
3663 means that the first .* in the pattern will only "eat up" all text in between "
3664 <script" and the first occurrence of "document.referrer", and that the second .
3665 * will only span the text up to the first "</script>" tag. Furthermore, the s
3666 option says that the match may span multiple lines in the page, and the g
3667 option again means that the substitution is global.
3668
3669 So, to summarize, the pattern means: Match all scripts that contain the text
3670 "document.referrer". Remember the parts of the script from (and including) the
3671 start tag up to (and excluding) the string "document.referrer" as $1, and the
3672 part following that string, up to and including the closing tag, as $2.
3673
3674 Now the pattern is deciphered, but wasn't this about substituting things? So
3675 lets look at the substitute: $1"Not Your Business!"$2 is easy to read: The text
3676 remembered as $1, followed by "Not Your Business!" (including the quotation
3677 marks!), followed by the text remembered as $2. This produces an exact copy of
3678 the original string, with the middle part (the "document.referrer") replaced by
3679 "Not Your Business!".
3680
3681 The whole job now reads: Replace "document.referrer" by "Not Your Business!"
3682 wherever it appears inside a <script> tag. Note that this job won't break
3683 JavaScript syntax, since both the original and the replacement are
3684 syntactically valid string objects. The script just won't have access to the
3685 referrer information anymore.
3686
3687 We'll show you two other jobs from the JavaScript taming department, but this
3688 time only point out the constructs of special interest:
3689
3690 # The status bar is for displaying link targets, not pointless blahblah        
3691 #                                                                              
3692 s/window\.status\s*=\s*(['"]).*?\1/dUmMy=1/ig                                  
3693
3694 \s stands for whitespace characters (space, tab, newline, carriage return, form
3695 feed), so that \s* means: "zero or more whitespace". The ? in .*? makes this
3696 matching of arbitrary text ungreedy. (Note that the U option is not set). The
3697 ['"] construct means: "a single or a double quote". Finally, \1 is a
3698 backreference to the first parenthesis just like $1 above, with the difference
3699 that in the pattern, a backslash indicates a backreference, whereas in the
3700 substitute, it's the dollar.
3701
3702 So what does this job do? It replaces assignments of single- or double-quoted
3703 strings to the "window.status" object with a dummy assignment (using a variable
3704 name that is hopefully odd enough not to conflict with real variables in
3705 scripts). Thus, it catches many cases where e.g. pointless descriptions are
3706 displayed in the status bar instead of the link target when you move your mouse
3707 over links.
3708
3709 # Kill OnUnload popups. Yummy. Test: http://www.zdnet.com/zdsubs/yahoo/tree/yfs.html 
3710 #                                                                                    
3711 s/(<body [^>]*)onunload(.*>)/$1never$2/iU                                            
3712
3713 Including the OnUnload event binding in the HTML DOM was a CRIME. When I close
3714 a browser window, I want it to close and die. Basta. This job replaces the
3715 "onunload" attribute in "<body>" tags with the dummy word never. Note that the
3716 i option makes the pattern matching case-insensitive. Also note that ungreedy
3717 matching alone doesn't always guarantee a minimal match: In the first
3718 parenthesis, we had to use [^>]* instead of .* to prevent the match from
3719 exceeding the <body> tag if it doesn't contain "OnUnload", but the page's
3720 content does.
3721
3722 The last example is from the fun department:
3723
3724 FILTER: fun Fun text replacements                                              
3725                                                                                
3726 # Spice the daily news:                                                        
3727 #                                                                              
3728 s/microsoft(?!\.com)/MicroSuck/ig                                              
3729
3730 Note the (?!\.com) part (a so-called negative lookahead) in the job's pattern,
3731 which means: Don't match, if the string ".com" appears directly following
3732 "microsoft" in the page. This prevents links to microsoft.com from being
3733 trashed, while still replacing the word everywhere else.
3734
3735 # Buzzword Bingo (example for extended regex syntax)                           
3736 #                                                                              
3737 s* industry[ -]leading \                                                       
3738 |  cutting[ -]edge \                                                           
3739 |  customer[ -]focused \                                                       
3740 |  market[ -]driven \                                                          
3741 |  award[ -]winning # Comments are OK, too! \                                  
3742 |  high[ -]performance \                                                       
3743 |  solutions[ -]based \                                                        
3744 |  unmatched \                                                                 
3745 |  unparalleled \                                                              
3746 |  unrivalled \                                                                
3747 *<font color="red"><b>BINGO!</b></font> \                                      
3748 *igx                                                                           
3749
3750 The x option in this job turns on extended syntax, and allows for e.g. the
3751 liberal use of (non-interpreted!) whitespace for nicer formatting.
3752
3753 You get the idea?
3754
3755 -------------------------------------------------------------------------------
3756
3757 10. Templates
3758
3759 All Privoxy built-in pages, i.e. error pages such as the "404 - No Such Domain"
3760 error page, the "BLOCKED" page and all pages of its web-based user interface,
3761 are generated from templates. (Privoxy must be running for the above links to
3762 work as intended.)
3763
3764 These templates are stored in a subdirectory of the configuration directory
3765 called templates. On Unixish platforms, this is typically /etc/privoxy/
3766 templates/.
3767
3768 The templates are basically normal HTML files, but with place-holders (called
3769 symbols or exports), which Privoxy fills at run time. You can edit the
3770 templates with a normal text editor, should you want to customize them. (Not
3771 recommended for the casual user). Note that just like in configuration files,
3772 lines starting with # are ignored when the templates are filled in.
3773
3774 The place-holders are of the form @name@, and you will find a list of available
3775 symbols, which vary from template to template, in the comments at the start of
3776 each file. Note that these comments are not always accurate, and that it's
3777 probably best to look at the existing HTML code to find out which symbols are
3778 supported and what they are filled in with.
3779
3780 A special application of this substitution mechanism is to make whole blocks of
3781 HTML code disappear when a specific symbol is set. We use this for many
3782 purposes, one of them being to include the beta warning in all our user
3783 interface (CGI) pages when Privoxy in in an alpha or beta development stage:
3784
3785 <!-- @if-unstable-start -->                                                    
3786                                                                                
3787   ... beta warning HTML code goes here ...                                     
3788                                                                                
3789 <!-- if-unstable-end@ -->                                                      
3790
3791 If the "unstable" symbol is set, everything in between and including
3792 @if-unstable-start and if-unstable-end@ will disappear, leaving nothing but an
3793 empty comment:
3794
3795 <!--  -->                                                                      
3796
3797 There's also an if-then-else construct and an #include mechanism, but you'll
3798 sure find out if you are inclined to edit the templates ;-)
3799
3800 All templates refer to a style located at http://config.privoxy.org/
3801 send-stylesheet. This is, of course, locally served by Privoxy and the source
3802 for it can be found and edited in the cgi-style.css template.
3803
3804 -------------------------------------------------------------------------------
3805
3806 11. Contacting the Developers, Bug Reporting and Feature Requests
3807
3808 We value your feedback. In fact, we rely on it to improve Privoxy and its
3809 configuration. However, please note the following hints, so we can provide you
3810 with the best support:
3811
3812 -------------------------------------------------------------------------------
3813
3814 11.1. Get Support
3815
3816 For casual users, our support forum at SourceForge is probably best suited: 
3817 http://sourceforge.net/tracker/?group_id=11118&atid=211118
3818
3819 All users are of course welcome to discuss their issues on the users mailing
3820 list, where the developers also hang around.
3821
3822 -------------------------------------------------------------------------------
3823
3824 11.2. Report Bugs
3825
3826 Please report all bugs only through our bug tracker: http://sourceforge.net/
3827 tracker/?group_id=11118&atid=111118.
3828
3829 Before doing so, please make sure that the bug has not already been submitted
3830 and observe the additional hints at the top of the submit form.
3831
3832 Please try to verify that it is a Privoxy bug, and not a browser or site bug
3833 first. If unsure, try toggling off Privoxy, and see if the problem persists.
3834 The appendix of the user manual also has helpful information on action
3835 debugging. If you are using your own custom configuration, please try the stock
3836 configs to see if the problem is configuration related.
3837
3838 If not using the latest version, chances are that the bug has been found and
3839 fixed in the meantime. We would appreciate if you could take the time to 
3840 upgrade to the latest version (or even the latest CVS snapshot) and verify your
3841 bug, but this is not required for reporting.
3842
3843 -------------------------------------------------------------------------------
3844
3845 11.3. Request New Features
3846
3847 You are welcome to submit ideas on new features or other proposals for
3848 improvement through our feature request tracker at http://sourceforge.net/
3849 tracker/?atid=361118&group_id=11118.
3850
3851 -------------------------------------------------------------------------------
3852
3853 11.4. Report Ads or Other Actions-Related Problems
3854
3855 Please send feedback on ads that slipped through, innocent images that were
3856 blocked, and any other problems relating to the default.action file through our
3857 actions feedback mechanism located at http://www.privoxy.org/actions/. On this
3858 page, you will also find a bookmark which will take you back there from any
3859 troubled site and even pre-fill the form!
3860
3861 New, improved default.action files will occasionally be made available based on
3862 your feedback. These will be announced on the ijbswa-announce list and
3863 available from our the files section of our project page.
3864
3865 -------------------------------------------------------------------------------
3866
3867 11.5. Other
3868
3869 For any other issues, feel free to use the mailing lists. Technically
3870 interested users and people who wish to contribute to the project are also
3871 welcome on the developers list! You can find an overview of all Privoxy-related
3872 mailing lists, including list archives, at: http://sourceforge.net/mail/?
3873 group_id=11118.
3874
3875 -------------------------------------------------------------------------------
3876
3877 12. Privoxy Copyright, License and History
3878
3879 Copyright © 2001, 2002 by Privoxy Developers <developers@privoxy.org>
3880
3881 Some source code is based on code Copyright © 1997 by Anonymous Coders and
3882 Junkbusters, Inc. and licensed under the GNU General Public License.
3883
3884 -------------------------------------------------------------------------------
3885
3886 12.1. License
3887
3888 Privoxy is free software; you can redistribute it and/or modify it under the
3889 terms of the GNU General Public License, version 2, as published by the Free
3890 Software Foundation.
3891
3892 This program is distributed in the hope that it will be useful, but WITHOUT ANY
3893 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
3894 PARTICULAR PURPOSE. See the GNU General Public License for more details, which
3895 is available from the Free Software Foundation, Inc, 59 Temple Place - Suite
3896 330, Boston, MA 02111-1307, USA.
3897
3898 You should have received a copy of the GNU General Public License along with
3899 this program; if not, write to the
3900
3901  Free Software
3902  Foundation, Inc. 59 Temple Place - Suite 330
3903  Boston, MA 02111-1307
3904  USA 
3905
3906 -------------------------------------------------------------------------------
3907
3908 12.2. History
3909
3910 In the beginning, there was the Internet Junkbuster, by Anonymous Coders and 
3911 Junkbusters Corporation. It saved many users a lot of pain in the early days of
3912 web advertising and user tracking.
3913
3914 But the web, its protocols and standards, and with it, the techniques for
3915 forcing users to consume ads, give up autonomy over their browsing, and for
3916 spying on them, kept evolving. Unfortunately, the Internet Junkbuster did not.
3917 Version 2.0.2, published in 1998, was (and is) the last official release
3918 available from Junkbusters Corporation. Fortunately, it had been released under
3919 the GNU GPL, which allowed further development by others.
3920
3921 So Stefan Waldherr started maintaining an improved version of the software, to
3922 which eventually a number of people contributed patches. It could already
3923 replace banners with a transparent image, and had a first version of pop-up
3924 killing, but it was still very closely based on the original, with all its
3925 limitations, such as the lack of HTTP/1.1 support, flexible per-site
3926 configuration, or content modification. The last release from this effort was
3927 version 2.0.2-10, published in 2000.
3928
3929 Then, some developers picked up the thread, and started turning the software
3930 inside out, upside down, and then reassembled it, adding many new features
3931 along the way.
3932
3933 The result of this is Privoxy, whose first stable release, 3.0, was released
3934 August, 2002.
3935
3936 -------------------------------------------------------------------------------
3937
3938 12.3. Authors
3939
3940 Current Project Developers:
3941
3942  Jon Foster
3943  Andreas Oesterhelt
3944  Stefan Waldherr
3945  
3946  Thomas Steudten
3947  Rodney Stromlund
3948
3949 Current Project Contributors:
3950
3951  Rodrigo Barbosa (RPM specfiles)
3952  Moritz Barsnick
3953  Hal Burgiss (docs)
3954  Karsten Hopp (Red Hat)
3955  Alexander Lazic
3956  Gábor Lipták
3957  Guy
3958  Haroon Rafique
3959  Roland Rosenfeld (Debian)
3960  Georg Sauthoff (Gentoo)
3961  David Schmidt (OS/2, Mac OSX ports)
3962  Joerg Strohmayer (Amiga)
3963  Sarantis Paskalis
3964
3965 Based in part on code originally developed by:
3966
3967  Junkbusters Corp.
3968  Anonymous Coders
3969
3970 Thanks to the many people who have tested Privoxy, reported bugs, or made
3971 suggestions. These include (in alphabetical order):
3972
3973  Ken Arromdee
3974  Devin Bayer
3975  Reiner Buehl
3976  Andrew J. Caines
3977  Clifford Caoile
3978  Michael T. Davis
3979  Peter E
3980  Aaron Hamid
3981  Magnus Holmgren
3982  Daniel Leite
3983  Paul Lieverse
3984  Roberto Ragusa
3985  Maynard Riley
3986  Bart Schelstraete
3987  Darren Wiebe
3988  jwz
3989
3990 -------------------------------------------------------------------------------
3991
3992 13. See Also
3993
3994 Other references and sites of interest to Privoxy users:
3995
3996 http://www.privoxy.org/, the Privoxy Home page.
3997
3998 http://www.privoxy.org/faq/, the Privoxy FAQ.
3999
4000 http://sourceforge.net/projects/ijbswa/, the Project Page for Privoxy on       
4001 SourceForge.                                                                   
4002
4003 http://config.privoxy.org/, the web-based user interface. Privoxy must be      
4004 running for this to work. Shortcut: http://p.p/                                
4005
4006 http://www.privoxy.org/actions/, to submit "misses" to the developers.
4007
4008 http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/ijbswa/contrib/, cool and fun   
4009 ideas from Privoxy users.                                                      
4010
4011 http://www.junkbusters.com/ht/en/cookies.html, an explanation how cookies are  
4012 used to track web users.                                                       
4013
4014 http://www.junkbusters.com/ijb.html, the original Internet Junkbuster.
4015
4016 http://www.waldherr.org/junkbuster/, Stefan Waldherr's version of Junkbuster,  
4017 from which Privoxy was derived.                                                
4018
4019 http://privacy.net/analyze/, a useful site to check what information about you 
4020 is leaked while you browse the web.                                            
4021
4022 http://www.squid-cache.org/, a very popular caching proxy, which is often used 
4023 together with Privoxy.                                                         
4024
4025 http://www.privoxy.org/developer-manual/, the Privoxy developer manual.
4026
4027 -------------------------------------------------------------------------------
4028
4029 14. Appendix
4030
4031 14.1. Regular Expressions
4032
4033 Privoxy uses Perl-style "regular expressions" in its actions files and filter
4034 file, through the PCRE and PCRS libraries.
4035
4036 If you are reading this, you probably don't understand what "regular
4037 expressions" are, or what they can do. So this will be a very brief
4038 introduction only. A full explanation would require a book ;-)
4039
4040 Regular expressions provide a language to describe patterns that can be run
4041 against strings of characters (letter, numbers, etc), to see if they match the
4042 string or not. The patterns are themselves (sometimes complex) strings of
4043 literal characters, combined with wild-cards, and other special characters,
4044 called meta-characters. The "meta-characters" have special meanings and are
4045 used to build complex patterns to be matched against. Perl Compatible Regular
4046 Expressions are an especially convenient "dialect" of the regular expression
4047 language.
4048
4049 To make a simple analogy, we do something similar when we use wild-card
4050 characters when listing files with the dir command in DOS. *.* matches all
4051 filenames. The "special" character here is the asterisk which matches any and
4052 all characters. We can be more specific and use ? to match just individual
4053 characters. So "dir file?.text" would match "file1.txt", "file2.txt", etc. We
4054 are pattern matching, using a similar technique to "regular expressions"!
4055
4056 Regular expressions do essentially the same thing, but are much, much more
4057 powerful. There are many more "special characters" and ways of building complex
4058 patterns however. Let's look at a few of the common ones, and then some
4059 examples:
4060
4061 . - Matches any single character, e.g. "a", "A", "4", ":", or "@".
4062
4063 ? - The preceding character or expression is matched ZERO or ONE times. Either/
4064 or.                                                                            
4065
4066 + - The preceding character or expression is matched ONE or MORE times.
4067
4068 * - The preceding character or expression is matched ZERO or MORE times.
4069
4070 \ - The "escape" character denotes that the following character should be taken
4071 literally. This is used where one of the special characters (e.g. ".") needs to
4072 be taken literally and not as a special meta-character. Example: "example      
4073 \.com", makes sure the period is recognized only as a period (and not expanded 
4074 to its meta-character meaning of any single character).                        
4075
4076 [] - Characters enclosed in brackets will be matched if any of the enclosed    
4077 characters are encountered. For instance, "[0-9]" matches any numeric digit    
4078 (zero through nine). As an example, we can combine this with "+" to match any  
4079 digit one of more times: "[0-9]+".                                             
4080
4081 () - parentheses are used to group a sub-expression, or multiple               
4082 sub-expressions.                                                               
4083
4084 | - The "bar" character works like an "or" conditional statement. A match is   
4085 successful if the sub-expression on either side of "|" matches. As an example: 
4086 "/(this|that) example/" uses grouping and the bar character and would match    
4087 either "this example" or "that example", and nothing else.                     
4088
4089 These are just some of the ones you are likely to use when matching URLs with
4090 Privoxy, and is a long way from a definitive list. This is enough to get us
4091 started with a few simple examples which may be more illuminating:
4092
4093 /.*/banners/.* - A simple example that uses the common combination of "." and "
4094 *" to denote any character, zero or more times. In other words, any string at
4095 all. So we start with a literal forward slash, then our regular expression
4096 pattern (".*") another literal forward slash, the string "banners", another
4097 forward slash, and lastly another ".*". We are building a directory path here.
4098 This will match any file with the path that has a directory named "banners" in
4099 it. The ".*" matches any characters, and this could conceivably be more forward
4100 slashes, so it might expand into a much longer looking path. For example, this
4101 could match: "/eye/hate/spammers/banners/annoy_me_please.gif", or just "/
4102 banners/annoying.html", or almost an infinite number of other possible
4103 combinations, just so it has "banners" in the path somewhere.
4104
4105 A now something a little more complex:
4106
4107 /.*/adv((er)?ts?|ertis(ing|ements?))?/ - We have several literal forward
4108 slashes again ("/"), so we are building another expression that is a file path
4109 statement. We have another ".*", so we are matching against any conceivable
4110 sub-path, just so it matches our expression. The only true literal that must
4111 match our pattern is adv, together with the forward slashes. What comes after
4112 the "adv" string is the interesting part.
4113
4114 Remember the "?" means the preceding expression (either a literal character or
4115 anything grouped with "(...)" in this case) can exist or not, since this means
4116 either zero or one match. So "((er)?ts?|ertis(ing|ements?))" is optional, as
4117 are the individual sub-expressions: "(er)", "(ing|ements?)", and the "s". The "
4118 |" means "or". We have two of those. For instance, "(ing|ements?)", can expand
4119 to match either "ing" OR "ements?". What is being done here, is an attempt at
4120 matching as many variations of "advertisement", and similar, as possible. So
4121 this would expand to match just "adv", or "advert", or "adverts", or
4122 "advertising", or "advertisement", or "advertisements". You get the idea. But
4123 it would not match "advertizements" (with a "z"). We could fix that by changing
4124 our regular expression to: "/.*/adv((er)?ts?|erti(s|z)(ing|ements?))?/", which
4125 would then match either spelling.
4126
4127 /.*/advert[0-9]+\.(gif|jpe?g) - Again another path statement with forward
4128 slashes. Anything in the square brackets "[]" can be matched. This is using
4129 "0-9" as a shorthand expression to mean any digit one through nine. It is the
4130 same as saying "0123456789". So any digit matches. The "+" means one or more of
4131 the preceding expression must be included. The preceding expression here is
4132 what is in the square brackets -- in this case, any digit one through nine.
4133 Then, at the end, we have a grouping: "(gif|jpe?g)". This includes a "|", so
4134 this needs to match the expression on either side of that bar character also. A
4135 simple "gif" on one side, and the other side will in turn match either "jpeg"
4136 or "jpg", since the "?" means the letter "e" is optional and can be matched
4137 once or not at all. So we are building an expression here to match image GIF or
4138 JPEG type image file. It must include the literal string "advert", then one or
4139 more digits, and a "." (which is now a literal, and not a special character,
4140 since it is escaped with "\"), and lastly either "gif", or "jpeg", or "jpg".
4141 Some possible matches would include: "//advert1.jpg", "/nasty/ads/
4142 advert1234.gif", "/banners/from/hell/advert99.jpg". It would not match
4143 "advert1.gif" (no leading slash), or "/adverts232.jpg" (the expression does not
4144 include an "s"), or "/advert1.jsp" ("jsp" is not in the expression anywhere).
4145
4146 We are barely scratching the surface of regular expressions here so that you
4147 can understand the default Privoxy configuration files, and maybe use this
4148 knowledge to customize your own installation. There is much, much more that can
4149 be done with regular expressions. Now that you know enough to get started, you
4150 can learn more on your own :/
4151
4152 More reading on Perl Compatible Regular expressions: http://www.perldoc.com/
4153 perl5.6/pod/perlre.html
4154
4155 For information on regular expression based substitutions and their
4156 applications in filters, please see the filter file tutorial in this manual.
4157
4158 -------------------------------------------------------------------------------
4159
4160 14.2. Privoxy's Internal Pages
4161
4162 Since Privoxy proxies each requested web page, it is easy for Privoxy to trap
4163 certain special URLs. In this way, we can talk directly to Privoxy, and see how
4164 it is configured, see how our rules are being applied, change these rules and
4165 other configuration options, and even turn Privoxy's filtering off, all with a
4166 web browser. 
4167
4168 The URLs listed below are the special ones that allow direct access to Privoxy.
4169 Of course, Privoxy must be running to access these. If not, you will get a
4170 friendly error message. Internet access is not necessary either.
4171
4172   * Privoxy main page:
4173    
4174         http://config.privoxy.org/
4175        
4176     There is a shortcut: http://p.p/ (But it doesn't provide a fall-back to a
4177     real page, in case the request is not sent through Privoxy)
4178    
4179   * Show information about the current configuration, including viewing and
4180     editing of actions files:
4181    
4182         http://config.privoxy.org/show-status
4183        
4184   * Show the source code version numbers:
4185    
4186         http://config.privoxy.org/show-version
4187        
4188   * Show the browser's request headers:
4189    
4190         http://config.privoxy.org/show-request
4191        
4192   * Show which actions apply to a URL and why:
4193    
4194         http://config.privoxy.org/show-url-info
4195        
4196   * Toggle Privoxy on or off. In this case, "Privoxy" continues to run, but
4197     only as a pass-through proxy, with no actions taking place:
4198    
4199         http://config.privoxy.org/toggle
4200        
4201     Short cuts. Turn off, then on:
4202    
4203         http://config.privoxy.org/toggle?set=disable
4204        
4205         http://config.privoxy.org/toggle?set=enable
4206        
4207 These may be bookmarked for quick reference. See next. 
4208
4209 -------------------------------------------------------------------------------
4210
4211 14.2.1. Bookmarklets
4212
4213 Below are some "bookmarklets" to allow you to easily access a "mini" version of
4214 some of Privoxy's special pages. They are designed for MS Internet Explorer,
4215 but should work equally well in Netscape, Mozilla, and other browsers which
4216 support JavaScript. They are designed to run directly from your bookmarks - not
4217 by clicking the links below (although that should work for testing).
4218
4219 To save them, right-click the link and choose "Add to Favorites" (IE) or "Add
4220 Bookmark" (Netscape). You will get a warning that the bookmark "may not be
4221 safe" - just click OK. Then you can run the Bookmarklet directly from your
4222 favorites/bookmarks. For even faster access, you can put them on the "Links"
4223 bar (IE) or the "Personal Toolbar" (Netscape), and run them with a single
4224 click.
4225
4226   * Privoxy - Enable
4227    
4228   * Privoxy - Disable
4229    
4230   * Privoxy - Toggle Privoxy (Toggles between enabled and disabled)
4231    
4232   * Privoxy- View Status
4233    
4234   * Privoxy - Submit Actions File Feedback
4235    
4236   * Privoxy - Why?
4237    
4238 Credit: The site which gave us the general idea for these bookmarklets is 
4239 www.bookmarklets.com. They have more information about bookmarklets.
4240
4241 -------------------------------------------------------------------------------
4242
4243 14.3. Chain of Events
4244
4245 Let's take a quick look at the basic sequence of events when a web page is
4246 requested by your browser and Privoxy is on duty:
4247
4248   * First, your web browser requests a web page. The browser knows to send the
4249     request to Privoxy, which will in turn, relay the request to the remote web
4250     server after passing the following tests:
4251    
4252   * Privoxy traps any request for its own internal CGI pages (e.g http://p.p/)
4253     and sends the CGI page back to the browser.
4254    
4255   * Next, Privoxy checks to see if the URL matches any "+block" patterns. If
4256     so, the URL is then blocked, and the remote web server will not be
4257     contacted. "+handle-as-image" is then checked and if it does not match, an
4258     HTML "BLOCKED" page is sent back. Otherwise, if it does match, an image is
4259     returned. The type of image depends on the setting of "+set-image-blocker"
4260     (blank, checkerboard pattern, or an HTTP redirect to an image elsewhere).
4261    
4262   * Untrusted URLs are blocked. If URLs are being added to the trust file, then
4263     that is done.
4264    
4265   * If the URL pattern matches the "+fast-redirects" action, it is then
4266     processed. Unwanted parts of the requested URL are stripped.
4267    
4268   * Now the rest of the client browser's request headers are processed. If any
4269     of these match any of the relevant actions (e.g. "+hide-user-agent", etc.),
4270     headers are suppressed or forged as determined by these actions and their
4271     parameters.
4272    
4273   * Now the web server starts sending its response back (i.e. typically a web
4274     page and related data).
4275    
4276   * First, the server headers are read and processed to determine, among other
4277     things, the MIME type (document type) and encoding. The headers are then
4278     filtered as determined by the "+crunch-incoming-cookies", 
4279     "+session-cookies-only", and "+downgrade-http-version" actions.
4280    
4281   * If the "+kill-popups" action applies, and it is an HTML or JavaScript
4282     document, the popup-code in the response is filtered on-the-fly as it is
4283     received.
4284    
4285   * If a "+filter" or "+deanimate-gifs" action applies (and the document type
4286     fits the action), the rest of the page is read into memory (up to a
4287     configurable limit). Then the filter rules (from default.filter) are
4288     processed against the buffered content. Filters are applied in the order
4289     they are specified in the default.filter file. Animated GIFs, if present,
4290     are reduced to either the first or last frame, depending on the action
4291     setting.The entire page, which is now filtered, is then sent by Privoxy
4292     back to your browser.
4293    
4294     If neither "+filter" or "+deanimate-gifs" matches, then Privoxy passes the
4295     raw data through to the client browser as it becomes available.
4296    
4297   * As the browser receives the now (probably filtered) page content, it reads
4298     and then requests any URLs that may be embedded within the page source,
4299     e.g. ad images, stylesheets, JavaScript, other HTML documents (e.g.
4300     frames), sounds, etc. For each of these objects, the browser issues a new
4301     request. And each such request is in turn processed as above. Note that a
4302     complex web page may have many such embedded URLs.
4303    
4304 -------------------------------------------------------------------------------
4305
4306 14.4. Anatomy of an Action
4307
4308 The way Privoxy applies actions and filters to any given URL can be complex,
4309 and not always so easy to understand what is happening. And sometimes we need
4310 to be able to see just what Privoxy is doing. Especially, if something Privoxy
4311 is doing is causing us a problem inadvertently. It can be a little daunting to
4312 look at the actions and filters files themselves, since they tend to be filled
4313 with regular expressions whose consequences are not always so obvious.
4314
4315 One quick test to see if Privoxy is causing a problem or not, is to disable it
4316 temporarily. This should be the first troubleshooting step. See the
4317 Bookmarklets section on a quick and easy way to do this (be sure to flush
4318 caches afterward!). Looking at the logs is a good idea too.
4319
4320 Privoxy also provides the http://config.privoxy.org/show-url-info page that can
4321 show us very specifically how actions are being applied to any given URL. This
4322 is a big help for troubleshooting.
4323
4324 First, enter one URL (or partial URL) at the prompt, and then Privoxy will tell
4325 us how the current configuration will handle it. This will not help with
4326 filtering effects (i.e. the "+filter" action) from the default.filter file
4327 since this is handled very differently and not so easy to trap! It also will
4328 not tell you about any other URLs that may be embedded within the URL you are
4329 testing. For instance, images such as ads are expressed as URLs within the raw
4330 page source of HTML pages. So you will only get info for the actual URL that is
4331 pasted into the prompt area -- not any sub-URLs. If you want to know about
4332 embedded URLs like ads, you will have to dig those out of the HTML source. Use
4333 your browser's "View Page Source" option for this. Or right click on the ad,
4334 and grab the URL.
4335
4336 Let's try an example, google.com, and look at it one section at a time:
4337
4338  Matches for http://google.com:                                                
4339                                                                                
4340  In file: default.action [ View ] [ Edit ]                                     
4341                                                                                
4342 {-add-header                                                                   
4343  -block                                                                        
4344  -crunch-outgoing-cookies                                                      
4345  -crunch-incoming-cookies                                                      
4346  +deanimate-gifs{last}                                                         
4347  -downgrade-http-version                                                       
4348  +fast-redirects                                                               
4349  -filter{popups}                                                               
4350  -filter{fun}                                                                  
4351  -filter{shockwave-flash}                                                      
4352  -filter{crude-parental}                                                       
4353  +filter{html-annoyances}                                                      
4354  +filter{js-annoyances}                                                        
4355  +filter{content-cookies}                                                      
4356  +filter{webbugs}                                                              
4357  +filter{refresh-tags}                                                         
4358  +filter{nimda}                                                                
4359  +filter{banners-by-size}                                                      
4360  +hide-forwarded-for-headers                                                   
4361  +hide-from-header{block}                                                      
4362  +hide-referer{forge}                                                          
4363  -hide-user-agent                                                              
4364  -handle-as-image                                                              
4365  -kill-popups                                                                  
4366  -limit-connect                                                                
4367  +prevent-compression                                                          
4368  -send-vanilla-wafer                                                           
4369  -send-wafer                                                                   
4370  +session-cookies-only                                                         
4371  +set-image-blocker{pattern} }                                                 
4372 /                                                                              
4373                                                                                
4374  { -session-cookies-only }                                                     
4375  .google.com                                                                   
4376                                                                                
4377  { -fast-redirects }                                                           
4378  .google.com                                                                   
4379                                                                                
4380 In file: user.action [ View ] [ Edit ]                                         
4381 (no matches in this file)                                                      
4382
4383 This tells us how we have defined our "actions", and which ones match for our
4384 example, "google.com". The first listing is any matches for the standard.action
4385 file. No hits at all here on "standard". Then next is "default", or our
4386 default.action file. The large, multi-line listing, is how the actions are set
4387 to match for all URLs, i.e. our default settings. If you look at your "actions"
4388 file, this would be the section just below the "aliases" section near the top.
4389 This will apply to all URLs as signified by the single forward slash at the end
4390 of the listing -- "/".
4391
4392 But we can define additional actions that would be exceptions to these general
4393 rules, and then list specific URLs (or patterns) that these exceptions would
4394 apply to. Last match wins. Just below this then are two explicit matches for
4395 ".google.com". The first is negating our previous cookie setting, which was for
4396 "+session-cookies-only" (i.e. not persistent). So we will allow persistent
4397 cookies for google. The second turns off any "+fast-redirects" action, allowing
4398 this to take place unmolested. Note that there is a leading dot here --
4399 ".google.com". This will match any hosts and sub-domains, in the google.com
4400 domain also, such as "www.google.com". So, apparently, we have these two
4401 actions defined somewhere in the lower part of our default.action file, and
4402 "google.com" is referenced somewhere in these latter sections.
4403
4404 Then, for our user.action file, we again have no hits.
4405
4406 And finally we pull it all together in the bottom section and summarize how
4407 Privoxy is applying all its "actions" to "google.com": 
4408
4409  Final results:                                                                
4410                                                                                
4411  -add-header                                                                   
4412  -block                                                                        
4413  -crunch-outgoing-cookies                                                      
4414  -crunch-incoming-cookies                                                      
4415  +deanimate-gifs{last}                                                         
4416  -downgrade-http-version                                                       
4417  -fast-redirects                                                               
4418  -filter{popups}                                                               
4419  -filter{fun}                                                                  
4420  -filter{shockwave-flash}                                                      
4421  -filter{crude-parental}                                                       
4422  +filter{html-annoyances}                                                      
4423  +filter{js-annoyances}                                                        
4424  +filter{content-cookies}                                                      
4425  +filter{webbugs}                                                              
4426  +filter{refresh-tags}                                                         
4427  +filter{nimda}                                                                
4428  +filter{banners-by-size}                                                      
4429  +hide-forwarded-for-headers                                                   
4430  +hide-from-header{block}                                                      
4431  +hide-referer{forge}                                                          
4432  -hide-user-agent                                                              
4433  -handle-as-image                                                              
4434  -kill-popups                                                                  
4435  -limit-connect                                                                
4436  +prevent-compression                                                          
4437  -send-vanilla-wafer                                                           
4438  -send-wafer                                                                   
4439  -session-cookies-only                                                         
4440  +set-image-blocker{pattern}                                                   
4441
4442 Notice the only difference here to the previous listing, is to "fast-redirects"
4443 and "session-cookies-only".
4444
4445 Now another example, "ad.doubleclick.net":
4446
4447  { +block +handle-as-image }                                                   
4448   .ad.doubleclick.net                                                          
4449                                                                                
4450  { +block +handle-as-image }                                                   
4451   ad*.                                                                         
4452                                                                                
4453  { +block +handle-as-image }                                                   
4454   .doubleclick.net                                                             
4455
4456 We'll just show the interesting part here, the explicit matches. It is matched
4457 three different times. Each as an "+block +handle-as-image", which is the
4458 expanded form of one of our aliases that had been defined as: "+imageblock". (
4459 "Aliases" are defined in the first section of the actions file and typically
4460 used to combine more than one action.)
4461
4462 Any one of these would have done the trick and blocked this as an unwanted
4463 image. This is unnecessarily redundant since the last case effectively would
4464 also cover the first. No point in taking chances with these guys though ;-)
4465 Note that if you want an ad or obnoxious URL to be invisible, it should be
4466 defined as "ad.doubleclick.net" is done here -- as both a "+block" and an 
4467 "+handle-as-image". The custom alias "+imageblock" just simplifies the process
4468 and make it more readable.
4469
4470 One last example. Let's try "http://www.rhapsodyk.net/adsl/HOWTO/". This one is
4471 giving us problems. We are getting a blank page. Hmmm ...
4472
4473  Matches for http://www.rhapsodyk.net/adsl/HOWTO/:                             
4474                                                                                
4475  In file: default.action [ View ] [ Edit ]                                     
4476                                                                                
4477  {-add-header                                                                  
4478   -block                                                                       
4479   -crunch-incoming-cookies                                                     
4480   -crunch-outgoing-cookies                                                     
4481   +deanimate-gifs                                                              
4482   -downgrade-http-version                                                      
4483   +fast-redirects                                                              
4484   +filter{html-annoyances}                                                     
4485   +filter{js-annoyances}                                                       
4486   +filter{kill-popups}                                                         
4487   +filter{webbugs}                                                             
4488   +filter{nimda}                                                               
4489   +filter{banners-by-size}                                                     
4490   +filter{hal}                                                                 
4491   +filter{fun}                                                                 
4492   +hide-forwarded-for-headers                                                  
4493   +hide-from-header{block}                                                     
4494   +hide-referer{forge}                                                         
4495   -hide-user-agent                                                             
4496   -handle-as-image                                                             
4497   +kill-popups                                                                 
4498   +prevent-compression                                                         
4499   -send-vanilla-wafer                                                          
4500   -send-wafer                                                                  
4501   +session-cookies-only                                                        
4502   +set-image-blocker{blank} }                                                  
4503    /                                                                           
4504                                                                                
4505  { +block +handle-as-image }                                                   
4506   /ads                                                                         
4507
4508 Ooops, the "/adsl/" is matching "/ads"! But we did not want this at all! Now we
4509 see why we get the blank page. We could now add a new action below this that
4510 explicitly does not block ("{-block}") paths with "adsl". There are various
4511 ways to handle such exceptions. Example:
4512
4513  { -block }                                                                    
4514   /adsl                                                                        
4515
4516 Now the page displays ;-) Be sure to flush your browser's caches when making
4517 such changes. Or, try using Shift+Reload.
4518
4519 But now what about a situation where we get no explicit matches like we did
4520 with:
4521
4522  { +block +handle-as-image }                                                   
4523  /ads                                                                          
4524
4525 That actually was very telling and pointed us quickly to where the problem was.
4526 If you don't get this kind of match, then it means one of the default rules in
4527 the first section is causing the problem. This would require some guesswork,
4528 and maybe a little trial and error to isolate the offending rule. One likely
4529 cause would be one of the "{+filter}" actions. These tend to be harder to
4530 troubleshoot. Try adding the URL for the site to one of aliases that turn off
4531 "+filter":
4532
4533  {shop}                                                                        
4534  .quietpc.com                                                                  
4535  .worldpay.com   # for quietpc.com                                             
4536  .jungle.com                                                                   
4537  .scan.co.uk                                                                   
4538  .forbes.com                                                                   
4539
4540 "{shop}" is an "alias" that expands to "{ -filter -session-cookies-only }". Or
4541 you could do your own exception to negate filtering: 
4542
4543  {-filter}                                                                     
4544  .forbes.com                                                                   
4545
4546 This would turn off all filtering for that site. This would probably be most
4547 appropriately put in user.action, for local site exceptions.
4548
4549 Images that are inexplicably being blocked, may well be hitting the "+filter
4550 {banners-by-size}" rule, which assumes that images of certain sizes are ad
4551 banners (works well most of the time since these tend to be standardized).
4552
4553 "{fragile}" is an alias that disables most actions. This can be used as a last
4554 resort for problem sites. Remember to flush caches! If this still does not
4555 work, you will have to go through the remaining actions one by one to find
4556 which one(s) is causing the problem.
4557