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