Sync.
[privoxy.git] / doc / text / user-manual.txt
1 Privoxy User Manual
2
3 By: Privoxy Developers
4
5 $Id: user-manual.sgml,v 1.73 2002/04/10 18:45:15 swa Exp $
6
7 The user manual gives users information on how to install, configure and use
8 Privoxy.
9
10 Privoxy is a web proxy with advanced filtering capabilities for protecting
11 privacy, filtering web page content, managing cookies, controlling access, and
12 removing ads, banners, pop-ups and other obnoxious Internet junk. Privoxy has a
13 very flexible configuration and can be customized to suit individual needs and
14 tastes. Privoxy has application for both stand-alone systems and multi-user
15 networks.
16
17 Privoxy is based on the code of the Internet Junkbuster (tm). Junkbuster was
18 originally written by Junkbusters Corporation, and was released as free
19 open-source software under the GNU GPL. Stefan Waldherr made many improvements,
20 and started the SourceForge project to continue development.
21
22 Privoxy continues the Junkbuster tradition, but adds many refinements,
23 enhancements and new features.
24
25 You can find the latest version of the user manual at http://www.privoxy.org/
26 user-manual/. Please see the Contact section on how to contact the developers.
27
28 -------------------------------------------------------------------------------
29
30 Table of Contents
31  
32 1. Introduction
33    
34     1.1. New Features
35    
36 3. Installation
37    
38     3.1. Source
39        
40         3.1.1. Red Hat
41         3.1.2. SuSE
42         3.1.3. OS/2
43         3.1.4. Windows
44         3.1.5. Other
45        
46 4. Quickstart to Using Privoxy
47    
48     4.1. Command Line Options
49    
50 5. Privoxy Configuration
51    
52     5.1. Controlling Privoxy with Your Web Browser
53     5.2. Configuration Files Overview
54     5.3. The Main Configuration File
55        
56         5.3.1. Defining Other Configuration Files
57         5.3.2. Other Configuration Options
58         5.3.3. Access Control List (ACL)
59         5.3.4. Forwarding
60         5.3.5. Windows GUI Options
61        
62     5.4. The Actions File
63        
64         5.4.1. URL Domain and Path Syntax
65         5.4.2. Actions
66         5.4.3. Aliases
67        
68     5.5. The Filter File
69     5.6. Templates
70    
71 6. Contacting the Developers, Bug Reporting and Feature Requests
72    
73     6.1. Submitting Ads and "Action" Problems
74    
75 7. Copyright and History
76    
77     7.1. Copyright
78     7.2. History
79    
80 8. See Also
81 9. Appendix
82    
83     9.1. Regular Expressions
84     9.2. Privoxy's Internal Pages
85        
86         9.2.1. Bookmarklets
87        
88     9.3. Anatomy of an Action
89    
90 -------------------------------------------------------------------------------
91
92 1. Introduction
93
94 This documentation is included with the current beta version of Privoxy,
95 v.2.9.14, and is mostly complete at this point. The most up to date reference
96 for the time being is still the comments in the source files and in the
97 individual configuration files. Development of version 3.0 is currently nearing
98 completion, and includes many significant changes and enhancements over earlier
99 versions. The target release date for stable v3.0 is "soon" ;-).
100
101 Since this is a beta version, not all new features are well tested. This
102 documentation may be slightly out of sync as a result (especially with CVS
103 sources). And there may be bugs, though hopefully not many!
104
105 -------------------------------------------------------------------------------
106
107 1.1. New Features
108
109 In addition to Internet Junkbuster's traditional feature of ad and banner
110 blocking and cookie management, Privoxy provides new features, some of them
111 currently under development:
112
113   * Integrated browser based configuration and control utility (http://p.p).
114     Browser-based tracing of rule and filter effects.
115    
116   * Blocking of annoying pop-up browser windows.
117    
118   * HTTP/1.1 compliant (most, but not all 1.1 features are supported).
119    
120   * Support for Perl Compatible Regular Expressions in the configuration files,
121     and generally a more sophisticated and flexible configuration syntax over
122     previous versions.
123    
124   * GIF de-animation.
125    
126   * Web page content filtering (removes banners based on size, invisible
127     "web-bugs", JavaScript, pop-ups, status bar abuse, etc.)
128    
129   * Bypass many click-tracking scripts (avoids script redirection).
130    
131   * Multi-threaded (POSIX and native threads).
132    
133   * Auto-detection and re-reading of config file changes.
134    
135   * User-customizable HTML templates (e.g. 404 error page).
136    
137   * Improved cookie management features (e.g. session based cookies).
138    
139   * Improved signal handling, and a true daemon mode (Unix).
140    
141   * Builds from source on most UNIX-like systems. Packages available for: Linux
142     (RedHat, SuSE, or Debian), Windows, Sun Solaris, Mac OSX, OS/2, HP-UX 11
143     and AmigaOS.
144    
145   * In addition, the configuration is much more powerful and versatile
146     over-all.
147    
148 -------------------------------------------------------------------------------
149
150 3. Installation
151
152 Privoxy is available as raw source code (tarball or via CVS), or pre-compiled
153 binaries for various platforms. See the Privoxy Project Page for the most up to
154 date release information. Privoxy is also available via CVS. This is the
155 recommended approach at this time. But please be aware that CVS is constantly
156 changing, and it may break in mysterious ways.
157
158 At present, Privoxy is known to run on Win32, Mac OSX, OS/2, AmigaOS, Linux
159 (RedHat, Suse, Debian), FreeBSD, and many flavors of Unix. There are source and
160 binary releases for these available for download at http://sourceforge.net/
161 project/showfiles.php?group_id=11118.
162
163 -------------------------------------------------------------------------------
164
165 3.1. Source
166
167 There are several ways to install Privoxy.
168
169 To build Privoxy from source, autoconf and GNU make (gmake) are required.
170 Source is available as gzipped tar archives. For this, first unpack the source:
171
172  tar xzvf privoxy-2.9.14-beta-src* [.tgz or .tar.gz]                           
173  cd privoxy-2.9.14-beta                                                        
174                                                                                
175
176 For retrieving the current CVS sources, you'll need the CVS package installed
177 first. Note CVS source is development quality, and may not be stable, or well
178 tested. To download CVS source:
179
180   cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login          
181   cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa co current 
182   cd current                                                                         
183                                                                                      
184
185 This will create a directory named current/, which will contain the source
186 tree.
187
188 Then, in either case, to build from unpacked tarball or CVS source:
189
190  autoheader                                                                    
191  autoconf                                                                      
192  ./configure      (--help to see options)                                      
193  make             (the make from gnu, gmake for *BSD)                          
194  su                                                                            
195  make -n install  (to see where all the files will go)                         
196  make install     (to really install)                                          
197                                                                                
198
199 Redhat and SuSE src and binary RPMs can be built with "make redhat-dist" or "
200 make suse-dist" from unpacked sources. You will need to run "autoconf;
201 autoheader; ./configure" beforehand. *BSD will require gmake (from http://
202 www.gnu.org).
203
204 For Redhat and SuSE Linux RPM packages, see below.
205
206 -------------------------------------------------------------------------------
207
208 3.1.1. Red Hat
209
210 To build Redhat RPM packages from source, install source as above. Then:
211
212  autoheader                                                                    
213  autoconf                                                                      
214  ./configure                                                                   
215  make redhat-dist                                                              
216                                                                                
217
218 This will create both binary and src RPMs in the usual places. Example:
219
220    /usr/src/redhat/RPMS/i686/privoxy-2.9.14-1.i686.rpm
221
222    /usr/src/redhat/SRPMS/privoxy-2.9.14-1.src.rpm
223
224 To install, of course:
225
226  rpm -Uvv /usr/src/redhat/RPMS/i686/privoxy-2.9.14-1.i686.rpm                  
227                                                                                
228
229 This will place the Privoxy configuration files in /etc/privoxy/, and log files
230 in /var/log/privoxy/. Run "chkconfig privoxy on" to have Privoxy start
231 automatically during init. 
232
233 -------------------------------------------------------------------------------
234
235 3.1.2. SuSE
236
237 To build SuSE RPM packages, install source as above. Then:
238
239  autoheader                                                                    
240  autoconf                                                                      
241  ./configure                                                                   
242  make suse-dist                                                                
243                                                                                
244
245 This will create both binary and src RPMs in the usual places. Example:
246
247    /usr/src/packages/RPMS/i686/privoxy-2.9.14-1.i686.rpm
248
249    /usr/src/packages/SRPMS/privoxy-2.9.14-1.src.rpm
250
251 To install, of course:
252
253  rpm -Uvv /usr/src/packages/RPMS/i686/privoxy-2.9.14-1.i686.rpm                
254                                                                                
255
256 This will place the Privoxy configuration files in /etc/privoxy/, and log files
257 in /var/log/privoxy/.
258
259 -------------------------------------------------------------------------------
260
261 3.1.3. OS/2
262
263 Privoxy is packaged in a WarpIN self- installing archive. The self-installing
264 program will be named depending on the release version, something like:
265 privoxyos2_setup_2.9.14.exe. In order to install it, simply run this executable
266 or double-click on its icon and follow the WarpIN installation panels. A shadow
267 of the Privoxy executable will be placed in your startup folder so it will
268 start automatically whenever OS/2 starts.
269
270 The directory you choose to install Privoxy into will contain all of the
271 configuration files.
272
273 If you would like to build binary images on OS/2 yourself, you will need a few
274 Unix-like tools: autoconf, autoheader and sh. These tools will be used to
275 create the required config.h file, which is not part of the source distribution
276 because it differs based on platform. You will also need a compiler. The
277 distribution has been created using IBM VisualAge compilers, but you can use
278 any compiler you like. GCC/EMX has the disadvantage of needing to be
279 single-threaded due to a limitation of EMX's implementation of the select()
280 socket call.
281
282 In addition to needing the source code distribution as outlined earlier, you
283 will want to extract the os2seutp directory from CVS:
284
285  cvs -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa login           
286  cvs -z3 -d:pserver:anonymous@cvs.ijbswa.sourceforge.net:/cvsroot/ijbswa co os2setup 
287                                                                                      
288
289 This will create a directory named os2setup/, which will contain the
290 Makefile.vac makefile and os2build.cmd which is used to completely create the
291 binary distribution. The sequence of events for building the executable for
292 yourself goes something like this:
293
294  cd current                                                                    
295  autoheader                                                                    
296  autoconf                                                                      
297  sh configure                                                                  
298  cd ..\os2setup                                                                
299  nmake -f Makefile.vac                                                         
300                                                                                
301
302 You will see this sequence laid out in os2build.cmd.
303
304 -------------------------------------------------------------------------------
305
306 3.1.4. Windows
307
308 Click-click. (I need help on this. Not a clue here. Also for configuration
309 section below. HB.)
310
311 -------------------------------------------------------------------------------
312
313 3.1.5. Other
314
315 Some quick notes on other Operating Systems.
316
317 For FreeBSD (and other *BSDs?), the build will require gmake instead of the
318 included make. gmake is available from http://www.gnu.org. The rest should be
319 the same as above for Linux/Unix.
320
321 -------------------------------------------------------------------------------
322
323 4. Quickstart to Using Privoxy
324
325 Before launching Privoxy for the first time, you will want to configure your
326 browser(s) to use Privoxy as a HTTP and HTTPS proxy. The default is localhost
327 for the proxy address, and port 8118 (earlier versions used port 800). This is
328 the one required configuration that must be done!
329
330 With Netscape (and Mozilla), this can be set under Edit -> Preferences ->
331 Advanced -> Proxies -> HTTP Proxy. For Internet Explorer: Tools -> Internet
332 Properties -> Connections -> LAN Setting. Then, check "Use Proxy" and fill in
333 the appropriate info (Address: localhost, Port: 8118). Include if HTTPS proxy
334 support too.
335
336 After doing this, flush your browser's disk and memory caches to force a
337 re-reading of all pages and get rid of any ads that may be cached. You are now
338 ready to start enjoying the benefits of using Privoxy.
339
340 Privoxy is typically started by specifying the main configuration file to be
341 used on the command line. Example Unix startup command:
342
343                                                                                
344  # /usr/sbin/privoxy /etc/privoxy/config                                       
345                                                                                
346                                                                                
347
348 An init script is provided for SuSE and Redhat.
349
350 For for SuSE: /etc/rc.d/privoxy start
351
352 For RedHat: /etc/rc.d/init.d/privoxy start
353
354 If no configuration file is specified on the command line, Privoxy will look
355 for a file named config in the current directory. Except on Win32 where it will
356 try config.txt. If no file is specified on the command line and no default
357 configuration file can be found, Privoxy will fail to start.
358
359 The included default configuration files should give a reasonable starting
360 point, though may be somewhat aggressive in blocking junk. Most of the per site
361 configuration is done in the "actions" files. These are where various cookie
362 actions are defined, ad and banner blocking, and other aspects of Privoxy
363 configuration. There are several such files included, with varying levels of
364 aggressiveness.
365
366 You will probably want to keep an eye out for sites that require persistent
367 cookies, and add these to default.action as needed. By default, most of these
368 will be accepted only during the current browser session, until you add them to
369 the configuration. If you want the browser to handle this instead, you will
370 need to edit default.action and disable this feature. If you use more than one
371 browser, it would make more sense to let Privoxy handle this. In which case,
372 the browser(s) should be set to accept all cookies.
373
374 Privoxy is HTTP/1.1 compliant, but not all 1.1 features are as yet implemented.
375 If browsers that support HTTP/1.1 (like Mozilla or recent versions of I.E.)
376 experience problems, you might try to force HTTP/1.0 compatibility. For
377 Mozilla, look under Edit -> Preferences -> Debug -> Networking. Or set the
378 "+downgrade" config option in default.action.
379
380 After running Privoxy for a while, you can start to fine tune the configuration
381 to suit your personal, or site, preferences and requirements. There are many,
382 many aspects that can be customized. "Actions" (as specified in default.action)
383 can be adjusted by pointing your browser to http://p.p/, and then follow the
384 link to "edit the actions list". (This is an internal page and does not require
385 Internet access.)
386
387 In fact, various aspects of Privoxy configuration can be viewed from this page,
388 including current configuration parameters, source code version numbers, the
389 browser's request headers, and "actions" that apply to a given URL. In addition
390 to the default.action file editor mentioned above, Privoxy can also be turned
391 "on" and "off" from this page.
392
393 If you encounter problems, please verify it is a Privoxy bug, by disabling
394 Privoxy, and then trying the same page. Also, try another browser if possible
395 to eliminate browser or site problems. Before reporting it as a bug, see if
396 there is not a configuration option that is enabled that is causing the page
397 not to load. You can then add an exception for that page or site. For instance,
398 try adding it to the {fragile} section of default.action. This will turn off
399 most actions for this site. For more on troubleshooting problem sites, see the 
400 Appendix. If a bug, please report it to the developers (see below).
401
402 -------------------------------------------------------------------------------
403
404 4.1. Command Line Options
405
406 Privoxy may be invoked with the following command-line options:
407
408   * --version
409    
410     Print version info and exit, Unix only.
411    
412   * --help
413    
414     Print a short usage info and exit, Unix only.
415    
416   * --no-daemon
417    
418     Don't become a daemon, i.e. don't fork and become process group leader,
419     don't detach from controlling tty. Unix only.
420    
421   * --pidfile FILE
422    
423     On startup, write the process ID to FILE. Delete the FILE on exit. Failiure
424     to create or delete the FILE is non-fatal. If no FILE option is given, no
425     PID file will be used. Unix only.
426    
427   * --user USER[.GROUP]
428    
429     After (optionally) writing the PID file, assume the user ID of USER, and if
430     included the GID of GROUP. Exit if the privileges are not sufficient to do
431     so. Unix only.
432    
433   * configfile
434    
435     If no configfile is included on the command line, Privoxy will look for a
436     file named "config" in the current directory (except on Win32 where it will
437     look for "config.txt" instead). Specify full path to avoid confusion.
438    
439 -------------------------------------------------------------------------------
440
441 5. Privoxy Configuration
442
443 All Privoxy configuration is stored in text files. These files can be edited
444 with a text editor. Many important aspects of Privoxy can also be controlled
445 easily with a web browser.
446
447 -------------------------------------------------------------------------------
448
449 5.1. Controlling Privoxy with Your Web Browser
450
451 Privoxy can be reached by the special URL http://p.p/ (or alternately http://
452 config.privoxy.org/), which is an internal page. You will see the following
453 section: 
454
455 Please choose from the following options:                                      
456                                                                                
457     * Show information about the current configuration                         
458     * Show the source code version numbers                                     
459     * Show the client's request headers.                                       
460     * Show which actions apply to a URL and why                                
461     * Toggle Privoxy on or off                                                 
462     * Edit the actions list                                                    
463                                                                                
464                                                                                
465
466 This should be self-explanatory. Note the last item is an editor for the
467 "actions list", which is where much of the ad, banner, cookie, and URL blocking
468 magic is configured as well as other advanced features of Privoxy. This is an
469 easy way to adjust various aspects of Privoxy configuration. The actions file,
470 and other configuration files, are explained in detail below. Privoxy will
471 automatically detect any changes to these files.
472
473 "Toggle Privoxy On or Off" is handy for sites that might have problems with
474 your current actions and filters, or just to test if a site misbehaves, whether
475 it is Privoxy causing the problem or not. Privoxy continues to run as a proxy
476 in this case, but all filtering is disabled. 
477
478 -------------------------------------------------------------------------------
479
480 5.2. Configuration Files Overview
481
482 For Unix, *BSD and Linux, all configuration files are located in /etc/privoxy/
483 by default. For MS Windows, OS/2, and AmigaOS these are all in the same
484 directory as the Privoxy executable. The name and number of configuration files
485 has changed from previous versions, and is subject to change as development
486 progresses.
487
488 The installed defaults provide a reasonable starting point, though possibly
489 aggressive by some standards. For the time being, there are only three default
490 configuration files (this may change in time):
491
492   * The main configuration file is named config on Linux, Unix, BSD, OS/2, and
493     AmigaOS and config.txt on Windows.
494    
495   * The default.action file is used to define various "actions" relating to
496     images, banners, pop-ups, access restrictions, banners and cookies. There
497     is a CGI based editor for this file that can be accessed via http://p.p.
498     (Other actions files are included as well with differing levels of
499     filtering and blocking, e.g. basic.action.)
500    
501   * The default.filter file can be used to re-write the raw page content,
502     including viewable text as well as embedded HTML and JavaScript, and
503     whatever else lurks on any given web page.
504    
505 default.action and default.filter can use Perl style regular expressions for
506 maximum flexibility. All files use the "#" character to denote a comment. Such
507 lines are not processed by Privoxy. After making any changes, there is no need
508 to restart Privoxy in order for the changes to take effect. Privoxy should
509 detect such changes automatically.
510
511 While under development, the configuration content is subject to change. The
512 below documentation may not be accurate by the time you read this. Also, what
513 constitutes a "default" setting, may change, so please check all your
514 configuration files on important issues.
515
516 -------------------------------------------------------------------------------
517
518 5.3. The Main Configuration File
519
520 Again, the main configuration file is named config on Linux/Unix/BSD and OS/2,
521 and config.txt on Windows. Configuration lines consist of an initial keyword
522 followed by a list of values, all separated by whitespace (any number of spaces
523 or tabs). For example:
524
525   blockfile blocklist.ini
526    
527
528 Indicates that the blockfile is named "blocklist.ini". (A default installation
529 does not use this.)
530
531 A "#" indicates a comment. Any part of a line following a "#" is ignored,
532 except if the "#" is preceded by a "\".
533
534 Thus, by placing a "#" at the start of an existing configuration line, you can
535 make it a comment and it will be treated as if it weren't there. This is called
536 "commenting out" an option and can be useful to turn off features: If you
537 comment out the "logfile" line, Privoxy will not log to a file at all. Watch
538 for the "default:" section in each explanation to see what happens if the
539 option is left unset (or commented out).
540
541 Long lines can be continued on the next line by using a "\" as the very last
542 character.
543
544 There are various aspects of Privoxy behavior that can be tuned.
545
546 -------------------------------------------------------------------------------
547
548 5.3.1. Defining Other Configuration Files
549
550 Privoxy can use a number of other files to tell it what ads to block, what
551 cookies to accept, and perform other functions. This section of the
552 configuration file tells Privoxy where to find all those other files.
553
554 On Windows and AmigaOS, Privoxy looks for these files in the same directory as
555 the executable. On Unix and OS/2, Privoxy looks for these files in the current
556 working directory. In either case, an absolute path name can be used to avoid
557 problems.
558
559 When development goes modular and multi-user, the blocker, filter, and per-user
560 config will be stored in subdirectories of "confdir". For now, only confdir/
561 templates is used for storing HTML templates for CGI results.
562
563 The location of the configuration files:
564
565   confdir /etc/privoxy       # No trailing /, please.
566    
567
568 The directory where all logging (i.e. logfile and jarfile) takes place. No
569 trailing "/", please:
570
571   logdir /var/log/privoxy
572    
573
574 Note that all file specifications below are relative to the above two
575 directories!
576
577 The "default.action" file contains patterns to specify the actions to apply to
578 requests for each site. Default: Cookies to and from all destinations are kept
579 only during the current browser session (i.e. they are not saved to disk).
580 Pop-ups are disabled for all sites. All sites are filtered through selected
581 sections of "default.filter". No sites are blocked. Privoxy displays a
582 checkboard type pattern for filtered ads and other images. The syntax of this
583 file is explained in detail below. Other "actions" files are included, and you
584 are free to use any of them. They have varying degrees of aggressiveness.
585
586   actionsfile default.action
587    
588
589 The "default.filter" file contains content modification rules that use "regular
590 expressions". These rules permit powerful changes on the content of Web pages,
591 e.g., you could disable your favorite JavaScript annoyances, re-write the
592 actual displayed text, or just have some fun replacing "Microsoft" with
593 "MicroSuck" wherever it appears on a Web page. Default: whatever the developers
594 are playing with :-/
595
596 Filtering requires buffering the page content, which may appear to slow down
597 page rendering since nothing is displayed until all content has passed the
598 filters. (It does not really take longer, but seems that way since the page is
599 not incrementally displayed.) This effect will be more noticeable on slower
600 connections. 
601
602   filterfile default.filter
603    
604
605 The logfile is where all logging and error messages are written. The logfile
606 can be useful for tracking down a problem with Privoxy (e.g., it's not blocking
607 an ad you think it should block) but in most cases you probably will never look
608 at it.
609
610 Your logfile will grow indefinitely, and you will probably want to periodically
611 remove it. On Unix systems, you can do this with a cron job (see "man cron").
612 For Redhat, a logrotate script has been included.
613
614 On SuSE Linux systems, you can place a line like "/var/log/privoxy.* +1024k 644
615 nobody.nogroup" in /etc/logfiles, with the effect that cron.daily will
616 automatically archive, gzip, and empty the log, when it exceeds 1M size.
617
618 Default: Log to the a file named logfile. Comment out to disable logging.
619
620   logfile logfile
621    
622
623 The "jarfile" defines where Privoxy stores the cookies it intercepts. Note that
624 if you use a "jarfile", it may grow quite large. Default: Don't store
625 intercepted cookies.
626
627   #jarfile jarfile
628    
629
630 If you specify a "trustfile", Privoxy will only allow access to sites that are
631 named in the trustfile. You can also mark sites as trusted referrers, with the
632 effect that access to untrusted sites will be granted, if a link from a trusted
633 referrer was used. The link target will then be added to the "trustfile". This
634 is a very restrictive feature that typical users most probably want to leave
635 disabled. Default: Disabled, don't use the trust mechanism.
636
637   #trustfile trust
638    
639
640 If you use the trust mechanism, it is a good idea to write up some on-line
641 documentation about your blocking policy and to specify the URL(s) here. They
642 will appear on the page that your users receive when they try to access
643 untrusted content. Use multiple times for multiple URLs. Default: Don't display
644 links on the "untrusted" info page.
645
646   trust-info-url http://www.example.com/why_we_block.html
647   trust-info-url http://www.example.com/what_we_allow.html
648    
649
650 -------------------------------------------------------------------------------
651
652 5.3.2. Other Configuration Options
653
654 This part of the configuration file contains options that control how Privoxy
655 operates.
656
657 "Admin-address" should be set to the email address of the proxy administrator.
658 It is used in many of the proxy-generated pages. Default: fill@me.in.please.
659
660   #admin-address fill@me.in.please
661    
662
663 "Proxy-info-url" can be set to a URL that contains more info about this Privoxy
664 installation, it's configuration and policies. It is used in many of the
665 proxy-generated pages and its use is highly recommended in multi-user
666 installations, since your users will want to know why certain content is
667 blocked or modified. Default: Don't show a link to on-line documentation.
668
669   proxy-info-url http://www.example.com/proxy.html
670    
671
672 "Listen-address" specifies the address and port where Privoxy will listen for
673 connections from your Web browser. The default is to listen on the localhost
674 port 8118, and this is suitable for most users. (In your web browser, under
675 proxy configuration, list the proxy server as "localhost" and the port as
676 "8118").
677
678 If you already have another service running on port 8118, or if you want to
679 serve requests from other machines (e.g. on your local network) as well, you
680 will need to override the default. The syntax is "listen-address
681 [<ip-address>]:<port>". If you leave out the IP address, Privoxy will bind to
682 all interfaces (addresses) on your machine and may become reachable from the
683 Internet. In that case, consider using access control lists (acl's) (see
684 "aclfile" above), or a firewall.
685
686 For example, suppose you are running Privoxy on a machine which has the address
687 192.168.0.1 on your local private network (192.168.0.0) and has another outside
688 connection with a different address. You want it to serve requests from inside
689 only:
690
691   listen-address 192.168.0.1:8118
692    
693
694 If you want it to listen on all addresses (including the outside connection):
695
696   listen-address :8118
697    
698
699 If you do this, consider using ACLs (see "aclfile" above). Note: you will need
700 to point your browser(s) to the address and port that you have configured here.
701 Default: localhost:8118 (127.0.0.1:8118).
702
703 The debug option sets the level of debugging information to log in the logfile
704 (and to the console in the Windows version). A debug level of 1 is informative
705 because it will show you each request as it happens. Higher levels of debug are
706 probably only of interest to developers.
707
708   debug         1 # GPC   = show each GET/POST/CONNECT request
709   debug         2 # CONN  = show each connection status
710   debug         4 # IO    = show I/O status
711   debug         8 # HDR   = show header parsing
712   debug        16 # LOG   = log all data into the logfile
713   debug        32 # FRC   = debug force feature
714   debug        64 # REF   = debug regular expression filter 
715   debug       128 #       = debug fast redirects
716   debug       256 #       = debug GIF de-animation
717   debug       512 # CLF   = Common Log Format
718   debug      1024 #       = debug kill pop-ups
719   debug      4096 # INFO  = Startup banner and warnings.
720   debug      8192 # ERROR = Non-fatal errors
721     
722
723 It is highly recommended that you enable ERROR reporting (debug 8192), at least
724 until v3.0 is released.
725
726 The reporting of FATAL errors (i.e. ones which crash Privoxy) is always on and
727 cannot be disabled.
728
729 If you want to use CLF (Common Log Format), you should set "debug 512" ONLY, do
730 not enable anything else.
731
732 Multiple "debug" directives, are OK - they're logical-OR'd together.
733
734   debug 15 # same as setting the first 4 listed above
735    
736
737 Default:
738
739   debug 1 # URLs
740   debug 4096 # Info
741   debug 8192 # Errors - *we highly recommended enabling this*
742    
743
744 Privoxy normally uses "multi-threading", a software technique that permits it
745 to handle many different requests simultaneously. In some cases you may wish to
746 disable this -- particularly if you're trying to debug a problem. The
747 "single-threaded" option forces Privoxy to handle requests sequentially.
748 Default: Multi-threaded mode.
749
750   #single-threaded
751    
752
753 "toggle" allows you to temporarily disable all Privoxy's filtering. Just set
754 "toggle 0".
755
756 The Windows version of Privoxy puts an icon in the system tray, which also
757 allows you to change this option. If you right-click on that icon (or select
758 the "Options" menu), one choice is "Enable". Clicking on enable toggles Privoxy
759 on and off. This is useful if you want to temporarily disable Privoxy, e.g., to
760 access a site that requires cookies which you would otherwise have blocked.
761 This can also be toggled via a web browser at the Privoxy internal address of 
762 http://p.p on any platform.
763
764 "toggle 1" means Privoxy runs normally, "toggle 0" means that Privoxy becomes a
765 non-anonymizing non-blocking proxy. Default: 1 (on).
766
767   toggle 1
768    
769
770 For content filtering, i.e. the "+filter" and "+deanimate-gif" actions, it is
771 necessary that Privoxy buffers the entire document body. This can be
772 potentially dangerous, since a server could just keep sending data indefinitely
773 and wait for your RAM to exhaust. With nasty consequences.
774
775 The buffer-limit option lets you set the maximum size in Kbytes that each
776 buffer may use. When the documents buffer exceeds this size, it is flushed to
777 the client unfiltered and no further attempt to filter the rest of it is made.
778 Remember that there may multiple threads running, which might require
779 increasing the "buffer-limit" Kbytes each, unless you have enabled
780 "single-threaded" above.
781
782   buffer-limit 4069
783    
784
785 To enable the web-based default.action file editor set enable-edit-actions to
786 1, or 0 to disable. Note that you must have compiled Privoxy with support for
787 this feature, otherwise this option has no effect. This internal page can be
788 reached at http://p.p.
789
790 Security note: If this is enabled, anyone who can use the proxy can edit the
791 actions file, and their changes will affect all users. For shared proxies, you
792 probably want to disable this. Default: enabled.
793
794   enable-edit-actions 1
795    
796
797 Allow Privoxy to be toggled on and off remotely, using your web browser. Set
798 "enable-remote-toggle"to 1 to enable, and 0 to disable. Note that you must have
799 compiled Privoxy with support for this feature, otherwise this option has no
800 effect.
801
802 Security note: If this is enabled, anyone who can use the proxy can toggle it
803 on or off (see http://p.p), and their changes will affect all users. For shared
804 proxies, you probably want to disable this. Default: enabled.
805
806   enable-remote-toggle 1
807    
808
809 -------------------------------------------------------------------------------
810
811 5.3.3. Access Control List (ACL)
812
813 Access controls are included at the request of some ISPs and systems
814 administrators, and are not usually needed by individual users. Please note the
815 warnings in the FAQ that this proxy is not intended to be a substitute for a
816 firewall or to encourage anyone to defer addressing basic security weaknesses.
817
818 If no access settings are specified, the proxy talks to anyone that connects.
819 If any access settings file are specified, then the proxy talks only to IP
820 addresses permitted somewhere in this file and not denied later in this file.
821
822 Summary -- if using an ACL:
823
824 Client must have permission to receive service.
825
826 LAST match in ACL wins.
827
828 Default behavior is to deny service.
829
830 The syntax for an entry in the Access Control List is:
831
832   ACTION    SRC_ADDR[/SRC_MASKLEN]    [ DST_ADDR[/DST_MASKLEN] ]
833    
834
835 Where the individual fields are:
836
837  ACTION      = "permit-access" or "deny-access"
838
839  SRC_ADDR    = client hostname or dotted IP address
840  SRC_MASKLEN = number of bits in the subnet mask for the source
841
842  DST_ADDR    = server or forwarder hostname or dotted IP address
843  DST_MASKLEN = number of bits in the subnet mask for the target
844    
845
846 The field separator (FS) is whitespace (space or tab).
847
848 IMPORTANT NOTE: If Privoxy is using a forwarder (see below) or a gateway for a
849 particular destination URL, the DST_ADDR that is examined is the address of the
850 forwarder or the gateway and NOT the address of the ultimate target. This is
851 necessary because it may be impossible for the local Privoxy to determine the
852 address of the ultimate target (that's often what gateways are used for).
853
854 Here are a few examples to show how the ACL features work:
855
856 "localhost" is OK -- no DST_ADDR implies that ALL destination addresses are OK:
857
858   permit-access localhost
859    
860
861 A silly example to illustrate permitting any host on the class-C subnet with
862 Privoxy to go anywhere:
863
864   permit-access www.privoxy.com/24
865    
866
867 Except deny one particular IP address from using it at all:
868
869   deny-access ident.privoxy.com
870    
871
872 You can also specify an explicit network address and subnet mask. Explicit
873 addresses do not have to be resolved to be used.
874
875   permit-access 207.153.200.0/24
876    
877
878 A subnet mask of 0 matches anything, so the next line permits everyone.
879
880   permit-access 0.0.0.0/0
881    
882
883 Note, you cannot say:
884
885   permit-access .org
886    
887
888 to allow all *.org domains. Every IP address listed must resolve fully.
889
890 An ISP may want to provide a Privoxy that is accessible by "the world" and yet
891 restrict use of some of their private content to hosts on its internal network
892 (i.e. its own subscribers). Say, for instance the ISP owns the Class-B IP
893 address block 123.124.0.0 (a 16 bit netmask). This is how they could do it:
894
895  permit-access 0.0.0.0/0 0.0.0.0/0   # other clients can go anywhere 
896                                        # with the following exceptions:
897  
898  deny-access   0.0.0.0/0   123.124.0.0/16 # block all external requests for
899                                           # sites on the ISP's network
900
901  permit 0.0.0.0/0 www.my_isp.com        # except for the ISP's main 
902                                           # web site
903
904  permit 123.124.0.0/16 0.0.0.0/0          # the ISP's clients can go 
905                                           # anywhere
906    
907
908 Note that if some hostnames are listed with multiple IP addresses, the primary
909 value returned by DNS (via gethostbyname()) is used. Default: Anyone can access
910 the proxy.
911
912 -------------------------------------------------------------------------------
913
914 5.3.4. Forwarding
915
916 This feature allows chaining of HTTP requests via multiple proxies. It can be
917 used to better protect privacy and confidentiality when accessing specific
918 domains by routing requests to those domains to a special purpose filtering
919 proxy such as lpwa.com. Or to use a caching proxy to speed up browsing.
920
921 It can also be used in an environment with multiple networks to route requests
922 via multiple gateways allowing transparent access to multiple networks without
923 having to modify browser configurations.
924
925 Also specified here are SOCKS proxies. Privoxy SOCKS 4 and SOCKS 4A. The
926 difference is that SOCKS 4A will resolve the target hostname using DNS on the
927 SOCKS server, not our local DNS client.
928
929 The syntax of each line is:
930
931  forward target_domain[:port] http_proxy_host[:port]
932  forward-socks4 target_domain[:port] socks_proxy_host[:port] http_proxy_host[:
933 port]
934  forward-socks4a target_domain[:port] socks_proxy_host[:port] http_proxy_host[:
935 port]
936    
937
938 If http_proxy_host is ".", then requests are not forwarded to a HTTP proxy but
939 are made directly to the web servers.
940
941 Lines are checked in sequence, and the last match wins.
942
943 There is an implicit line equivalent to the following, which specifies that
944 anything not finding a match on the list is to go out without forwarding or
945 gateway protocol, like so:
946
947   forward .* . # implicit
948    
949
950 In the following common configuration, everything goes to Lucent's LPWA, except
951 SSL on port 443 (which it doesn't handle):
952
953  forward .* lpwa.com:8000
954  forward :443 .
955    
956
957 Some users have reported difficulties related to LPWA's use of "." as the last
958 element of the domain, and have said that this can be fixed with this:
959
960   forward lpwa. lpwa.com:8000
961    
962
963 (NOTE: the syntax for specifying target_domain has changed since the previous
964 paragraph was written -- it will not work now. More information is welcome.)
965
966 In this fictitious example, everything goes via an ISP's caching proxy, except
967 requests to that ISP:
968
969  forward .* caching.myisp.net:8000
970  forward myisp.net .
971    
972
973 For the @home network, we're told the forwarding configuration is this:
974
975   forward .* proxy:8080
976    
977
978 Also, we're told they insist on getting cookies and JavaScript, so you should
979 allow cookies from home.com. We consider JavaScript a potential security risk.
980 Java need not be enabled.
981
982 In this example direct connections are made to all "internal" domains, but
983 everything else goes through Lucent's LPWA by way of the company's SOCKS
984 gateway to the Internet.
985
986  forward-socks4 .* lpwa.com:8000 firewall.my_company.com:1080
987  forward my_company.com .
988    
989
990 This is how you could set up a site that always uses SOCKS but no forwarders:
991
992   forward-socks4a .* . firewall.my_company.com:1080
993    
994
995 An advanced example for network administrators:
996
997 If you have links to multiple ISPs that provide various special content to
998 their subscribers, you can configure forwarding to pass requests to the
999 specific host that's connected to that ISP so that everybody can see all of the
1000 content on all of the ISPs.
1001
1002 This is a bit tricky, but here's an example:
1003
1004 host-a has a PPP connection to isp-a.com. And host-b has a PPP connection to
1005 isp-b.com. host-a can run a Privoxy proxy with forwarding like this:
1006
1007  forward .* .
1008  forward isp-b.com host-b:8118
1009    
1010
1011 host-b can run a Privoxy proxy with forwarding like this:
1012
1013  forward .* .
1014  forward isp-a.com host-a:8118
1015    
1016
1017 Now, anyone on the Internet (including users on host-a and host-b) can set
1018 their browser's proxy to either host-a or host-b and be able to browse the
1019 content on isp-a or isp-b.
1020
1021 Here's another practical example, for University of Kent at Canterbury students
1022 with a network connection in their room, who need to use the University's Squid
1023 web cache.
1024
1025  forward *. ssbcache.ukc.ac.uk:3128  # Use the proxy, except for:
1026  forward .ukc.ac.uk .  # Anything on the same domain as us
1027  forward * .  # Host with no domain specified
1028  forward 129.12.*.* .  # A dotted IP on our /16 network.
1029  forward 127.*.*.* .  # Loopback address
1030  forward localhost.localdomain .  # Loopback address
1031  forward www.ukc.mirror.ac.uk .  # Specific host
1032    
1033
1034 If you intend to chain Privoxy and squid locally, then chain as browser ->
1035 squid -> privoxy is the recommended way.
1036
1037 Your squid configuration could then look like this (assuming that the IP
1038 address of the box is 192.168.0.1 ):
1039
1040   # Define Privoxy as parent cache 
1041   
1042   cache_peer 192.168.0.1 parent 8118 0 no-query
1043
1044   # don't listen to the whole world
1045   http_port 192.168.0.1:3128
1046
1047   # define the local lan
1048   acl mylocallan src 192.168.0.1-192.168.0.5/255.255.255.255
1049
1050   # grant access for http to local lan
1051   http_access allow mylocallan
1052   
1053   # Define ACL for protocol FTP 
1054   acl FTP proto FTP 
1055
1056   # Do not forward ACL FTP to privoxy
1057   always_direct allow FTP 
1058
1059   # Do not forward ACL CONNECT (https) to privoxy
1060   always_direct allow CONNECT 
1061
1062   # Forward the rest to privoxy
1063   never_direct allow all 
1064    
1065
1066 -------------------------------------------------------------------------------
1067
1068 5.3.5. Windows GUI Options
1069
1070 Privoxy has a number of options specific to the Windows GUI interface:
1071
1072 If "activity-animation" is set to 1, the Privoxy icon will animate when
1073 "Privoxy" is active. To turn off, set to 0.
1074
1075   activity-animation 1
1076    
1077
1078 If "log-messages" is set to 1, Privoxy will log messages to the console window:
1079
1080   log-messages 1
1081    
1082
1083 If "log-buffer-size" is set to 1, the size of the log buffer, i.e. the amount
1084 of memory used for the log messages displayed in the console window, will be
1085 limited to "log-max-lines" (see below).
1086
1087 Warning: Setting this to 0 will result in the buffer to grow infinitely and eat
1088 up all your memory!
1089
1090   log-buffer-size 1
1091    
1092
1093 log-max-lines is the maximum number of lines held in the log buffer. See above.
1094
1095   log-max-lines 200
1096    
1097
1098 If "log-highlight-messages" is set to 1, Privoxy will highlight portions of the
1099 log messages with a bold-faced font:
1100
1101   log-highlight-messages 1
1102    
1103
1104 The font used in the console window:
1105
1106   log-font-name Comic Sans MS
1107    
1108
1109 Font size used in the console window:
1110
1111   log-font-size 8
1112    
1113
1114 "show-on-task-bar" controls whether or not Privoxy will appear as a button on
1115 the Task bar when minimized:
1116
1117   show-on-task-bar 0
1118    
1119
1120 If "close-button-minimizes" is set to 1, the Windows close button will minimize
1121 Privoxy instead of closing the program (close with the exit option on the File
1122 menu).
1123
1124   close-button-minimizes 1
1125    
1126
1127 The "hide-console" option is specific to the MS-Win console version of Privoxy.
1128 If this option is used, Privoxy will disconnect from and hide the command
1129 console.
1130
1131   #hide-console
1132    
1133
1134 -------------------------------------------------------------------------------
1135
1136 5.4. The Actions File
1137
1138 The "default.action" file (formerly actionsfile or ijb.action) is used to
1139 define what actions Privoxy takes, and thus determines how ad images, cookies
1140 and various other aspects of HTTP content and transactions are handled. These
1141 can be accepted or rejected for all sites, or just those sites you choose. See
1142 below for a complete list of actions.
1143
1144 Anything you want can blocked, including ads, banners, or just some obnoxious
1145 URL that you would rather not see. Cookies can be accepted or rejected, or
1146 accepted only during the current browser session (i.e. not written to disk).
1147 Changes to default.action should be immediately visible to Privoxy without the
1148 need to restart.
1149
1150 Note that some sites may misbehave, or possibly not work at all with some
1151 actions. This may require some tinkering with the rules to get the most mileage
1152 of Privoxy's features, and still be able to see and enjoy just what you want
1153 to. There is no general rule of thumb on these things. There just are too many
1154 variables, and sites are always changing. 
1155
1156 The easiest way to edit the "actions" file is with a browser by loading http://
1157 p.p/, and then select "Edit Actions List". A text editor can also be used.
1158
1159 To determine which actions apply to a request, the URL of the request is
1160 compared to all patterns in this file. Every time it matches, the list of
1161 applicable actions for the URL is incrementally updated. You can trace this
1162 process by visiting http://p.p/show-url-info.
1163
1164 There are four types of lines in this file: comments (begin with a "#"
1165 character), actions, aliases and patterns, all of which are explained below, as
1166 well as the configuration file syntax that Privoxy understands. 
1167
1168 -------------------------------------------------------------------------------
1169
1170 5.4.1. URL Domain and Path Syntax
1171
1172 Generally, a pattern has the form <domain>/<path>, where both the <domain> and
1173 <path> part are optional. If you only specify a domain part, the "/" can be
1174 left out:
1175
1176 www.example.com - is a domain only pattern and will match any request to
1177 "www.example.com".
1178
1179 www.example.com/ - means exactly the same.
1180
1181 www.example.com/index.html - matches only the single document "/index.html" on
1182 "www.example.com".
1183
1184 /index.html - matches the document "/index.html", regardless of the domain. So
1185 would match any page named "index.html" on any site.
1186
1187 index.html - matches nothing, since it would be interpreted as a domain name
1188 and there is no top-level domain called ".html".
1189
1190 The matching of the domain part offers some flexible options: if the domain
1191 starts or ends with a dot, it becomes unanchored at that end. For example:
1192
1193 .example.com - matches any domain or sub-domain that ENDS in ".example.com".
1194
1195 www. - matches any domain that STARTS with "www".
1196
1197 Additionally, there are wild-cards that you can use in the domain names
1198 themselves. They work pretty similar to shell wild-cards: "*" stands for zero
1199 or more arbitrary characters, "?" stands for any single character. And you can
1200 define character classes in square brackets and they can be freely mixed:
1201
1202 ad*.example.com - matches "adserver.example.com", "ads.example.com", etc but
1203 not "sfads.example.com".
1204
1205 *ad*.example.com - matches all of the above, and then some.
1206
1207 .?pix.com - matches "www.ipix.com", "pictures.epix.com", "a.b.c.d.e.upix.com",
1208 etc.
1209
1210 www[1-9a-ez].example.com - matches "www1.example.com", "www4.example.com",
1211 "wwwd.example.com", "wwwz.example.com", etc., but not "wwww.example.com".
1212
1213 If Privoxy was compiled with "pcre" support (the default), Perl compatible
1214 regular expressions can be used. These are more flexible and powerful than
1215 other types of "regular expressions". See the pcre/docs/ directory or "man
1216 perlre" (also available on http://www.perldoc.com/perl5.6/pod/perlre.html) for
1217 details. A brief discussion of regular expressions is in the Appendix. For
1218 instance:
1219
1220 /.*/advert[0-9]+\.jpe?g - would match a URL from any domain, with any path that
1221 includes "advert" followed immediately by one or more digits, then a "." and
1222 ending in either "jpeg" or "jpg". So we match "example.com/ads/advert2.jpg",
1223 and "www.example.com/ads/banners/advert39.jpeg", but not "www.example.com/ads/
1224 banners/advert39.gif" (no gifs in the example pattern).
1225
1226 Please note that matching in the path is case INSENSITIVE by default, but you
1227 can switch to case sensitive at any point in the pattern by using the "(?-i)"
1228 switch:
1229
1230 www.example.com/(?-i)PaTtErN.* - will match only documents whose path starts
1231 with "PaTtErN" in exactly this capitalization.
1232
1233 -------------------------------------------------------------------------------
1234
1235 5.4.2. Actions
1236
1237 Actions are enabled if preceded with a "+", and disabled if preceded with a
1238 "-". Actions are invoked by enclosing the action name in curly braces (e.g.
1239 {+some_action}), followed by a list of URLs to which the action applies. There
1240 are three classes of actions:
1241
1242   * Boolean (e.g. "+/-block"):
1243    
1244       {+name}        # enable this action
1245       {-name}        # disable this action
1246          
1247    
1248   * parameterized (e.g. "+/-hide-user-agent"):
1249    
1250       {+name{param}}  # enable action and set parameter to "param"
1251       {-name}         # disable action
1252          
1253    
1254   * Multi-value (e.g. "{+/-add-header{Name: value}}", "{+/-wafer{name=value}}
1255     "):
1256    
1257       {+name{param}}   # enable action and add parameter "param"
1258       {-name{param}}   # remove the parameter "param"
1259       {-name}          # disable this action totally
1260          
1261    
1262 If nothing is specified in this file, no "actions" are taken. So in this case
1263 Privoxy would just be a normal, non-blocking, non-anonymizing proxy. You must
1264 specifically enable the privacy and blocking features you need (although the
1265 provided default default.action file will give a good starting point).
1266
1267 Later defined actions always over-ride earlier ones. So exceptions to any rules
1268 you make, should come in the latter part of the file. For multi-valued actions,
1269 the actions are applied in the order they are specified.
1270
1271 The list of valid Privoxy "actions" are:
1272
1273   * Add the specified HTTP header, which is not checked for validity. You may
1274     specify this many times to specify many different headers:
1275    
1276       +add-header{Name: value}
1277          
1278    
1279   * Block this URL totally. In a default installation, a "blocked" URL will
1280     result in bright red banner that says "BLOCKED", with a reason why it is
1281     being blocked, and an option to see it anyway. The page displayed for this
1282     is the "blocked" template file.
1283    
1284       +block
1285          
1286    
1287   * De-animate all animated GIF images, i.e. reduce them to their last frame.
1288     This will also shrink the images considerably (in bytes, not pixels!). If
1289     the option "first" is given, the first frame of the animation is used as
1290     the replacement. If "last" is given, the last frame of the animation is
1291     used instead, which probably makes more sense for most banner animations,
1292     but also has the risk of not showing the entire last frame (if it is only a
1293     delta to an earlier frame).
1294    
1295       +deanimate-gifs{last}
1296       +deanimate-gifs{first}
1297          
1298    
1299   * "+downgrade" will downgrade HTTP/1.1 client requests to HTTP/1.0 and
1300     downgrade the responses as well. Use this action for servers that use HTTP/
1301     1.1 protocol features that Privoxy doesn't handle well yet. HTTP/1.1 is
1302     only partially implemented. Default is not to downgrade requests.
1303    
1304       +downgrade
1305          
1306    
1307   * Many sites, like yahoo.com, don't just link to other sites. Instead, they
1308     will link to some script on their own server, giving the destination as a
1309     parameter, which will then redirect you to the final target. URLs resulting
1310     from this scheme typically look like: http://some.place/some_script?http://
1311     some.where-else.
1312    
1313     Sometimes, there are even multiple consecutive redirects encoded in the
1314     URL. These redirections via scripts make your web browsing more traceable,
1315     since the server from which you follow such a link can see where you go to.
1316     Apart from that, valuable bandwidth and time is wasted, while your browser
1317     ask the server for one redirect after the other. Plus, it feeds the
1318     advertisers.
1319    
1320     The "+fast-redirects" option enables interception of these types of
1321     requests by Privoxy, who will cut off all but the last valid URL in the
1322     request and send a local redirect back to your browser without contacting
1323     the intermediate site(s).
1324    
1325       +fast-redirects
1326          
1327    
1328   * Apply the filters in the section_header section of the default.filter file
1329     to the site(s). default.filter sections are grouped according to like
1330     functionality. Filters can be used to re-write any of the raw page content.
1331     This is a potentially a very powerful feature!
1332    
1333      +filter{section_header}
1334          
1335    
1336     Filter sections that are pre-defined in the supplied default.filter
1337     include:
1338    
1339         html-annoyances: Get rid of particularly annoying HTML abuse.
1340        
1341         js-annoyances: Get rid of particularly annoying JavaScript abuse
1342        
1343         no-poups: Kill all popups in JS and HTML
1344        
1345         frameset-borders: Give frames a border
1346        
1347         webbugs: Squish WebBugs (1x1 invisible GIFs used for user tracking)
1348        
1349         no-refresh: Automatic refresh sucks on auto-dialup lines
1350        
1351         fun: Text replacements for subversive browsing fun!
1352        
1353         nimda: Remove (virus) Nimda code.
1354        
1355         banners-by-size: Kill banners by size
1356        
1357         crude-parental: Kill all web pages that contain the words "sex" or     
1358         "warez"                                                                
1359        
1360   * Block any existing X-Forwarded-for header, and do not add a new one:
1361    
1362       +hide-forwarded
1363          
1364    
1365   * If the browser sends a "From:" header containing your e-mail address, this
1366     either completely removes the header ("block"), or changes it to the
1367     specified e-mail address.
1368    
1369       +hide-from{block}
1370       +hide-from{spam@sittingduck.xqq}
1371          
1372    
1373   * Don't send the "Referer:" (sic) header to the web site. You can block it,
1374     forge a URL to the same server as the request (which is preferred because
1375     some sites will not send images otherwise) or set it to a constant, user
1376     defined string of your choice.
1377    
1378       +hide-referer{block}
1379       +hide-referer{forge}
1380       +hide-referer{http://nowhere.com}
1381          
1382    
1383   * Alternative spelling of "+hide-referer". It has the same parameters, and
1384     can be freely mixed with, "+hide-referer". ("referrer" is the correct
1385     English spelling, however the HTTP specification has a bug - it requires it
1386     to be spelled "referer".)
1387    
1388       +hide-referrer{...}
1389          
1390    
1391   * Change the "User-Agent:" header so web servers can't tell your browser
1392     type. Warning! This breaks many web sites. Specify the user-agent value you
1393     want. Example, pretend to be using Netscape on Linux:
1394    
1395       +hide-user-agent{Mozilla (X11; I; Linux 2.0.32 i586)}
1396          
1397    
1398   * Treat this URL as an image. This only matters if it's also "+block"ed, in
1399     which case a "blocked" image can be sent rather than a HTML page. See
1400     "+image-blocker{}" below for the control over what is actually sent. If you
1401     want invisible ads, they should be defined as images and blocked. And also,
1402     "image-blocker" should be set to "blank". Note you cannot treat HTML pages
1403     as images in most cases. For instance, frames require an HTML page to
1404     display. So a frame that is an ad, cannot be treated as an image. Forcing
1405     an "image" in this situation just will not work.
1406    
1407       +image
1408          
1409    
1410   * Decides what to do with URLs that end up tagged with "{+block +image}", e.g
1411     an advertizement. There are five options. "-image-blocker" will send a HTML
1412     "blocked" page, usually resulting in a "broken image" icon. "+image-blocker
1413     {blank}" will send a 1x1 transparent GIF image. And finally,
1414     "+image-blocker{http://xyz.com}" will send a HTTP temporary redirect to the
1415     specified image. This has the advantage of the icon being being cached by
1416     the browser, which will speed up the display. "+image-blocker{pattern}"
1417     will send a checkboard type pattern
1418    
1419       +image-blocker{blank}
1420       +image-blocker{pattern}
1421       +image-blocker{http://p.p/send-banner}
1422          
1423    
1424   * By default (i.e. in the absence of a "+limit-connect" action), Privoxy will
1425     only allow CONNECT requests to port 443, which is the standard port for
1426     https as a precaution.
1427    
1428     The CONNECT methods exists in HTTP to allow access to secure websites
1429     (https:// URLs) through proxies. It works very simply: the proxy connects
1430     to the server on the specified port, and then short-circuits its
1431     connections to the client and to the remote proxy. This can be a big
1432     security hole, since CONNECT-enabled proxies can be abused as TCP relays
1433     very easily.
1434    
1435     If you want to allow CONNECT for more ports than this, or want to forbid
1436     CONNECT altogether, you can specify a comma separated list of ports and
1437     port ranges (the latter using dashes, with the minimum defaulting to 0 and
1438     max to 65K):
1439    
1440       +limit-connect{443} # This is the default and need no be specified.
1441       +limit-connect{80,443} # Ports 80 and 443 are OK.
1442       +limit-connect{-3, 7, 20-100, 500-} # Port less than 3, 7, 20 to 100
1443        #and above 500 are OK.
1444          
1445    
1446   * "+no-compression" prevents the website from compressing the data. Some
1447     websites do this, which can be a problem for Privoxy, since "+filter",
1448     "+no-popup" and "+gif-deanimate" will not work on compressed data. This
1449     will slow down connections to those websites, though. Default is
1450     "no-compression" is turned on.
1451    
1452       +nocompression
1453          
1454    
1455   * If the website sets cookies, "no-cookies-keep" will make sure they are
1456     erased when you exit and restart your web browser. This makes profiling
1457     cookies useless, but won't break sites which require cookies so that you
1458     can log in for transactions. Default: on.
1459    
1460       +no-cookies-keep
1461          
1462    
1463   * Prevent the website from reading cookies:
1464    
1465       +no-cookies-read
1466          
1467    
1468   * Prevent the website from setting cookies:
1469    
1470       +no-cookies-set
1471          
1472    
1473   * Filter the website through a built-in filter to disable those obnoxious
1474     JavaScript pop-up windows via window.open(), etc. The two alternative
1475     spellings are equivalent.
1476    
1477       +no-popup
1478       +no-popups
1479          
1480    
1481   * This action only applies if you are using a jarfile for saving cookies. It
1482     sends a cookie to every site stating that you do not accept any copyright
1483     on cookies sent to you, and asking them not to track you. Of course, this
1484     is a (relatively) unique header they could use to track you.
1485    
1486       +vanilla-wafer
1487          
1488    
1489   * This allows you to add an arbitrary cookie. It can be specified multiple
1490     times in order to add as many cookies as you like.
1491    
1492       +wafer{name=value}
1493          
1494    
1495 The meaning of any of the above is reversed by preceding the action with a "-",
1496 in place of the "+".
1497
1498 Some examples:
1499
1500 Turn off cookies by default, then allow a few through for specified sites:
1501
1502  # Turn off all persistent cookies
1503  { +no-cookies-read }
1504  { +no-cookies-set }
1505  # Allow cookies for this browser session ONLY
1506  { +no-cookies-keep }
1507
1508  # Exceptions to the above, sites that benefit from persistent cookies
1509  { -no-cookies-read }
1510  { -no-cookies-set }
1511  { -no-cookies-keep }
1512  .javasoft.com
1513  .sun.com
1514  .yahoo.com
1515  .msdn.microsoft.com
1516  .redhat.com
1517
1518  # Alternative way of saying the same thing
1519  {-no-cookies-set -no-cookies-read -no-cookies-keep}
1520  .sourceforge.net
1521  .sf.net
1522    
1523
1524 Now turn off "fast redirects", and then we allow two exceptions:
1525
1526  # Turn them off!
1527  {+fast-redirects}
1528  
1529  # Reverse it for these two sites, which don't work right without it.
1530  {-fast-redirects}
1531  www.ukc.ac.uk/cgi-bin/wac\.cgi\?
1532  login.yahoo.com
1533    
1534
1535 Turn on page filtering according to rules in the defined sections of
1536 refilterfile, and make one exception for sourceforge:
1537
1538  # Run everything through the filter file, using only the
1539  # specified sections:
1540  +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups}\
1541  +filter{webbugs} +filter{nimda} +filter{banners-by-size}
1542               
1543  # Then disable filtering of code from sourceforge!
1544  {-filter}
1545  .cvs.sourceforge.net
1546    
1547
1548 Now some URLs that we want "blocked" (normally generates the "blocked" banner).
1549 Many of these use regular expressions that will expand to match multiple URLs:
1550
1551   # Blocklist:
1552   {+block}
1553   /.*/(.*[-_.])?ads?[0-9]?(/|[-_.].*|\.(gif|jpe?g))
1554   /.*/(.*[-_.])?count(er)?(\.cgi|\.dll|\.exe|[?/])
1555   /.*/(ng)?adclient\.cgi
1556   /.*/(plain|live|rotate)[-_.]?ads?/
1557   /.*/(sponsor)s?[0-9]?/
1558   /.*/_?(plain|live)?ads?(-banners)?/
1559   /.*/abanners/
1560   /.*/ad(sdna_image|gifs?)/
1561   /.*/ad(server|stream|juggler)\.(cgi|pl|dll|exe)
1562   /.*/adbanners/
1563   /.*/adserver
1564   /.*/adstream\.cgi
1565   /.*/adv((er)?ts?|ertis(ing|ements?))?/
1566   /.*/banner_?ads/
1567   /.*/banners?/
1568   /.*/banners?\.cgi/
1569   /.*/cgi-bin/centralad/getimage
1570   /.*/images/addver\.gif
1571   /.*/images/marketing/.*\.(gif|jpe?g)
1572   /.*/popupads/
1573   /.*/siteads/
1574   /.*/sponsor.*\.gif
1575   /.*/sponsors?[0-9]?/
1576   /.*/advert[0-9]+\.jpg
1577   /Media/Images/Adds/
1578   /ad_images/
1579   /adimages/
1580   /.*/ads/
1581   /bannerfarm/
1582   /grafikk/annonse/
1583   /graphics/defaultAd/
1584   /image\.ng/AdType
1585   /image\.ng/transactionID
1586   /images/.*/.*_anim\.gif # alvin brattli
1587   /ip_img/.*\.(gif|jpe?g)
1588   /rotateads/
1589   /rotations/ 
1590   /worldnet/ad\.cgi
1591   /cgi-bin/nph-adclick.exe/
1592   /.*/Image/BannerAdvertising/
1593   /.*/ad-bin/
1594   /.*/adlib/server\.cgi
1595   /autoads/
1596    
1597
1598 Note that many of these actions have the potential to cause a page to
1599 misbehave, possibly even not to display at all. There are many ways a site
1600 designer may choose to design his site, and what HTTP header content he may
1601 depend on. There is no way to have hard and fast rules for all sites. See the 
1602 Appendix for a brief example on troubleshooting actions.
1603
1604 -------------------------------------------------------------------------------
1605
1606 5.4.3. Aliases
1607
1608 Custom "actions", known to Privoxy as "aliases", can be defined by combining
1609 other "actions". These can in turn be invoked just like the built-in "actions".
1610 Currently, an alias can contain any character except space, tab, "=", "{" or "}
1611 ". But please use only "a"- "z", "0"-"9", "+", and "-". Alias names are not
1612 case sensitive, and must be defined before anything else in the
1613 default.actionfile! And there can only be one set of "aliases" defined.
1614
1615 Now let's define a few aliases:
1616
1617  # Useful custom aliases we can use later. These must come first!
1618  {{alias}}
1619  +no-cookies = +no-cookies-set +no-cookies-read
1620  -no-cookies = -no-cookies-set -no-cookies-read
1621  fragile     =
1622  -block -no-cookies -filter -fast-redirects -hide-referer -no-popups
1623  shop        = -no-cookies -filter -fast-redirects
1624  +imageblock = +block +image
1625
1626  #For people who don't like to type too much:  ;-)
1627  c0 = +no-cookies
1628  c1 = -no-cookies
1629  c2 = -no-cookies-set +no-cookies-read
1630  c3 = +no-cookies-set -no-cookies-read
1631  #... etc.  Customize to your heart's content.
1632    
1633
1634 Some examples using our "shop" and "fragile" aliases from above:
1635
1636  # These sites are very complex and require
1637  # minimal interference.
1638  {fragile}
1639  .office.microsoft.com
1640  .windowsupdate.microsoft.com
1641  .nytimes.com
1642
1643  # Shopping sites - still want to block ads.
1644  {shop}
1645  .quietpc.com
1646  .worldpay.com   # for quietpc.com
1647  .jungle.com
1648  .scan.co.uk
1649
1650  # These shops require pop-ups
1651  {shop -no-popups}
1652  .dabs.com
1653  .overclockers.co.uk
1654    
1655
1656 The "shop" and "fragile" aliases are often used for "problem" sites that
1657 require most actions to be disabled in order to function properly. 
1658
1659 -------------------------------------------------------------------------------
1660
1661 5.5. The Filter File
1662
1663 Any web page can be dynamically modified with the filter file. This
1664 modification can be removal, or re-writing, of any web page content, including
1665 tags and non-visible content. The default filter file is default.filter,
1666 located in the config directory.
1667
1668 This is potentially a very powerful feature, and requires knowledge of both
1669 "regular expression" and HTML in order create custom filters. But, there are a
1670 number of useful filters included with Privoxy for many common situations.
1671
1672 The included example file is divided into sections. Each section begins with
1673 the FILTER keyword, followed by the identifier for that section, e.g. "FILTER:
1674 webbugs". Each section performs a similar type of filtering, such as
1675 "html-annoyances".
1676
1677 This file uses regular expressions to alter or remove any string in the target
1678 page. The expressions can only operate on one line at a time. Some examples
1679 from the included default default.filter:
1680
1681 Stop web pages from displaying annoying messages in the status bar by deleting
1682 such references:
1683
1684  FILTER: html-annoyances
1685
1686  # New browser windows should be resizeable and have a location and status
1687  # bar. Make it so.
1688  #
1689  s/resizable="?(no|0)"?/resizable=1/ig s/noresize/yesresize/ig
1690  s/location="?(no|0)"?/location=1/ig s/status="?(no|0)"?/status=1/ig
1691  s/scrolling="?(no|0|Auto)"?/scrolling=1/ig
1692  s/menubar="?(no|0)"?/menubar=1/ig 
1693
1694  # The <BLINK> tag was a crime!
1695  #
1696  s*<blink>|</blink>**ig
1697
1698  # Is this evil? 
1699  #
1700  #s/framespacing="?(no|0)"?//ig
1701  #s/margin(height|width)=[0-9]*//gi
1702    
1703
1704 Just for kicks, replace any occurrence of "Microsoft" with "MicroSuck", and
1705 have a little fun with topical buzzwords:
1706
1707  FILTER: fun
1708
1709  s/microsoft(?!.com)/MicroSuck/ig
1710
1711  # Buzzword Bingo:
1712  #
1713  s/industry-leading|cutting-edge|award-winning/<font color=red><b>BINGO!</b></
1714 font>/ig
1715    
1716
1717 Kill those pesky little web-bugs:
1718
1719  # webbugs: Squish WebBugs (1x1 invisible GIFs used for user tracking)
1720  FILTER: webbugs
1721
1722  s/<img\s+[^>]*?(width|height)\s*=\s*['"]?1\D[^>]*?(width|height)\s*=\s*['"]?1
1723 (\D[^>]*?)?>/<!-- Squished WebBug -->/sig
1724    
1725
1726 -------------------------------------------------------------------------------
1727
1728 5.6. Templates
1729
1730 When Privoxy displays one of its internal pages, such as a 404 Not Found error
1731 page, it uses the appropriate template. On Linux, BSD, and Unix, these are
1732 located in /etc/privoxy/templates by default. These may be customized, if
1733 desired. cgi-style.css is used to control the HTML attributes (fonts, etc).
1734
1735 The default "Blocked" banner page with the bright red top banner, is called
1736 just "blocked". This may be customized or replaced with something else if
1737 desired. 
1738
1739 -------------------------------------------------------------------------------
1740
1741 6. Contacting the Developers, Bug Reporting and Feature Requests
1742
1743 We value your feedback. However, to provide you with the best support, please
1744 note:
1745
1746   *  Use the Sourceforge Support Forum to get help:
1747        
1748         http://sourceforge.net/tracker/?group_id=11118&atid=211118
1749        
1750    
1751   *  Submit bugs only through our Sourceforge Bug Forum:
1752      
1753         http://sourceforge.net/tracker/?group_id=11118&atid=111118. 
1754         
1755    
1756     Make sure that the bug has not already been submitted. Please try to verify
1757     that it is a Privoxy bug, and not a browser or site bug first. If you are
1758     using your own custom configuration, please try the stock configs to see if
1759     the problem is a configuration related bug. And if not using the latest
1760     development snapshot, please try the latest one. Or even better, CVS
1761     sources. Please be sure to include the Privoxy/Junkbuster version,
1762     platform, browser, any pertinent log data, any other relevant details
1763     (please be specific) and, if possible, some way to reproduce the bug.
1764    
1765   *  Submit feature requests only through our Sourceforge feature request forum:
1766      
1767         http://sourceforge.net/tracker/?atid=361118&group_id=11118&func=browse.
1768        
1769    
1770   *  Submit missed ads and banners, and incorrectly blocked images, popups, etc:
1771           
1772         http://p.p/, and select "actions file feedback system"
1773        
1774    
1775     This page can also be reached from many of the internal CGI pages.
1776    
1777   *  For any other issues, feel free to use the mailing lists:
1778      
1779         http://sourceforge.net/mail/?group_id=11118.
1780      
1781    
1782     Anyone interested in actively participating in development and related
1783     discussions can also join the appropriate mailing list. Archives are
1784     available too.
1785    
1786 -------------------------------------------------------------------------------
1787
1788 6.1. Submitting Ads and "Action" Problems
1789
1790 Ads and banners that are not stopped by Privoxy can be submitted to the
1791 developers by accessing a special page and filling out the brief, required
1792 form. Conversely, you can also report pages, images, etc. that Privoxy is
1793 blocking, but should not. The form itself does require Internet access.
1794
1795 To do this, point your browser to Privoxy at http://p.p/, and then select 
1796 Actions file feedback system, near the bottom of the page. Paste in the URL
1797 that is the cause of the unwanted behavior, and follow the prompts. The
1798 developers will try to incorporate your submission into future versions.
1799
1800 New default.actions files will occasionally be made available based on your
1801 feedback. These will be announced on the ijbswa-announce list.
1802
1803 -------------------------------------------------------------------------------
1804
1805 7. Copyright and History
1806
1807 7.1. Copyright
1808
1809 Privoxy is free software; you can redistribute it and/or modify it under the
1810 terms of the GNU General Public License as published by the Free Software
1811 Foundation; either version 2 of the License, or (at your option) any later
1812 version.
1813
1814 This program is distributed in the hope that it will be useful, but WITHOUT ANY
1815 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
1816 PARTICULAR PURPOSE. See the GNU General Public License for more details, which
1817 is available from the Free Software Foundation, Inc, 59 Temple Place - Suite
1818 330, Boston, MA 02111-1307, USA.
1819
1820 You should have received a copy of the GNU General Public License along with
1821 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
1822 Place, Suite 330, Boston, MA 02111-1307 USA.
1823
1824 -------------------------------------------------------------------------------
1825
1826 7.2. History
1827
1828 Privoxy is evolved, and derived from, the Internet Junkbuster, with many
1829 improvments and enhancements over the original.
1830
1831 Junkbuster was originally written by Anonymous Coders and Junkbusters
1832 Corporation, and was released as free open-source software under the GNU GPL. 
1833 Stefan Waldherr made many improvements, and started the SourceForge project
1834 Privoxy to rekindle development. There are now several active developers
1835 contributing. The last stable release of Junkbuster was v2.0.2, which has now
1836 grown whiskers ;-).
1837
1838 -------------------------------------------------------------------------------
1839
1840 8. See Also
1841
1842 Other references and sites of interest to Privoxy users:
1843
1844 http://www.privoxy.org/, The Privoxy Home page.
1845
1846 http://sourceforge.net/projects/ijbswa, the Project Page for Privoxy on        
1847 Sourceforge.                                                                   
1848
1849 http://p.p/, access Privoxy from your browser. Alternately, http://            
1850 config.privoxy.org may work in some situations where the first does not.       
1851
1852 http://p.p/, and select "actions file feedback system" to submit "misses" to   
1853 the developers.                                                                
1854
1855 http://www.junkbusters.com/ht/en/cookies.html
1856
1857 http://www.waldherr.org/junkbuster/
1858
1859 http://privacy.net/analyze/
1860
1861 http://www.squid-cache.org/
1862
1863  
1864
1865 -------------------------------------------------------------------------------
1866
1867 9. Appendix
1868
1869 9.1. Regular Expressions
1870
1871 Privoxy can use "regular expressions" in various config files. Assuming support
1872 for "pcre" (Perl Compatible Regular Expressions) is compiled in, which is the
1873 default. Such configuration directives do not require regular expressions, but
1874 they can be used to increase flexibility by matching a pattern with wild-cards
1875 against URLs.
1876
1877 If you are reading this, you probably don't understand what "regular
1878 expressions" are, or what they can do. So this will be a very brief
1879 introduction only. A full explanation would require a book ;-)
1880
1881 "Regular expressions" is a way of matching one character expression against
1882 another to see if it matches or not. One of the "expressions" is a literal
1883 string of readable characters (letter, numbers, etc), and the other is a
1884 complex string of literal characters combined with wild-cards, and other
1885 special characters, called meta-characters. The "meta-characters" have special
1886 meanings and are used to build the complex pattern to be matched against. Perl
1887 Compatible Regular Expressions is an enhanced form of the regular expression
1888 language with backward compatibility.
1889
1890 To make a simple analogy, we do something similar when we use wild-card
1891 characters when listing files with the dir command in DOS. *.* matches all
1892 filenames. The "special" character here is the asterisk which matches any and
1893 all characters. We can be more specific and use ? to match just individual
1894 characters. So "dir file?.text" would match "file1.txt", "file2.txt", etc. We
1895 are pattern matching, using a similar technique to "regular expressions"!
1896
1897 Regular expressions do essentially the same thing, but are much, much more
1898 powerful. There are many more "special characters" and ways of building complex
1899 patterns however. Let's look at a few of the common ones, and then some
1900 examples:
1901
1902 . - Matches any single character, e.g. "a", "A", "4", ":", or "@".
1903
1904 ? - The preceding character or expression is matched ZERO or ONE times. Either/
1905 or.                                                                            
1906
1907 + - The preceding character or expression is matched ONE or MORE times.
1908
1909 * - The preceding character or expression is matched ZERO or MORE times.
1910
1911 \ - The "escape" character denotes that the following character should be taken
1912 literally. This is used where one of the special characters (e.g. ".") needs to
1913 be taken literally and not as a special meta-character.                        
1914
1915 [] - Characters enclosed in brackets will be matched if any of the enclosed    
1916 characters are encountered.                                                    
1917
1918 () - parentheses are used to group a sub-expression, or multiple               
1919 sub-expressions.                                                               
1920
1921 | - The "bar" character works like an "or" conditional statement. A match is   
1922 successful if the sub-expression on either side of "|" matches.                
1923
1924 s/string1/string2/g - This is used to rewrite strings of text. "string1" is    
1925 replaced by "string2" in this example.                                         
1926
1927 These are just some of the ones you are likely to use when matching URLs with
1928 Privoxy, and is a long way from a definitive list. This is enough to get us
1929 started with a few simple examples which may be more illuminating:
1930
1931 /.*/banners/.* - A simple example that uses the common combination of "." and "
1932 *" to denote any character, zero or more times. In other words, any string at
1933 all. So we start with a literal forward slash, then our regular expression
1934 pattern (".*") another literal forward slash, the string "banners", another
1935 forward slash, and lastly another ".*". We are building a directory path here.
1936 This will match any file with the path that has a directory named "banners" in
1937 it. The ".*" matches any characters, and this could conceivably be more forward
1938 slashes, so it might expand into a much longer looking path. For example, this
1939 could match: "/eye/hate/spammers/banners/annoy_me_please.gif", or just "/
1940 banners/annoying.html", or almost an infinite number of other possible
1941 combinations, just so it has "banners" in the path somewhere.
1942
1943 A now something a little more complex:
1944
1945 /.*/adv((er)?ts?|ertis(ing|ements?))?/ - We have several literal forward
1946 slashes again ("/"), so we are building another expression that is a file path
1947 statement. We have another ".*", so we are matching against any conceivable
1948 sub-path, just so it matches our expression. The only true literal that must
1949 match our pattern is adv, together with the forward slashes. What comes after
1950 the "adv" string is the interesting part.
1951
1952 Remember the "?" means the preceding expression (either a literal character or
1953 anything grouped with "(...)" in this case) can exist or not, since this means
1954 either zero or one match. So "((er)?ts?|ertis(ing|ements?))" is optional, as
1955 are the individual sub-expressions: "(er)", "(ing|ements?)", and the "s". The "
1956 |" means "or". We have two of those. For instance, "(ing|ements?)", can expand
1957 to match either "ing" OR "ements?". What is being done here, is an attempt at
1958 matching as many variations of "advertisement", and similar, as possible. So
1959 this would expand to match just "adv", or "advert", or "adverts", or
1960 "advertising", or "advertisement", or "advertisements". You get the idea. But
1961 it would not match "advertizements" (with a "z"). We could fix that by changing
1962 our regular expression to: "/.*/adv((er)?ts?|erti(s|z)(ing|ements?))?/", which
1963 would then match either spelling.
1964
1965 /.*/advert[0-9]+\.(gif|jpe?g) - Again another path statement with forward
1966 slashes. Anything in the square brackets "[]" can be matched. This is using
1967 "0-9" as a shorthand expression to mean any digit one through nine. It is the
1968 same as saying "0123456789". So any digit matches. The "+" means one or more of
1969 the preceding expression must be included. The preceding expression here is
1970 what is in the square brackets -- in this case, any digit one through nine.
1971 Then, at the end, we have a grouping: "(gif|jpe?g)". This includes a "|", so
1972 this needs to match the expression on either side of that bar character also. A
1973 simple "gif" on one side, and the other side will in turn match either "jpeg"
1974 or "jpg", since the "?" means the letter "e" is optional and can be matched
1975 once or not at all. So we are building an expression here to match image GIF or
1976 JPEG type image file. It must include the literal string "advert", then one or
1977 more digits, and a "." (which is now a literal, and not a special character,
1978 since it is escaped with "\"), and lastly either "gif", or "jpeg", or "jpg".
1979 Some possible matches would include: "//advert1.jpg", "/nasty/ads/
1980 advert1234.gif", "/banners/from/hell/advert99.jpg". It would not match
1981 "advert1.gif" (no leading slash), or "/adverts232.jpg" (the expression does not
1982 include an "s"), or "/advert1.jsp" ("jsp" is not in the expression anywhere).
1983
1984 s/microsoft(?!.com)/MicroSuck/i - This is a substitution. "MicroSuck" will
1985 replace any occurrence of "microsoft". The "i" at the end of the expression
1986 means ignore case. The "(?!.com)" means the match should fail if "microsoft" is
1987 followed by ".com". In other words, this acts like a "NOT" modifier. In case
1988 this is a hyperlink, we don't want to break it ;-).
1989
1990 We are barely scratching the surface of regular expressions here so that you
1991 can understand the default Privoxy configuration files, and maybe use this
1992 knowledge to customize your own installation. There is much, much more that can
1993 be done with regular expressions. Now that you know enough to get started, you
1994 can learn more on your own :/
1995
1996 More reading on Perl Compatible Regular expressions: http://www.perldoc.com/
1997 perl5.6/pod/perlre.html
1998
1999 -------------------------------------------------------------------------------
2000
2001 9.2. Privoxy's Internal Pages
2002
2003 Since Privoxy proxies each requested web page, it is easy for Privoxy to trap
2004 certain special URLs. In this way, we can talk directly to Privoxy, and see how
2005 it is configured, see how our rules are being applied, change these rules and
2006 other configuration options, and even turn Privoxy's filtering off, all with a
2007 web browser. 
2008
2009 The URLs listed below are the special ones that allow direct access to Privoxy.
2010 Of course, Privoxy must be running to access these. If not, you will get a
2011 friendly error message. Internet access is not necessary either.
2012
2013   * Privoxy main page:
2014    
2015         http://config.privoxy.org/
2016        
2017     Alternately, this may be reached at http://p.p/, but this variation may not
2018     work as reliably as the above in some configurations.
2019    
2020   * Show information about the current configuration:
2021    
2022         http://config.privoxy.org/show-status
2023        
2024   * Show the source code version numbers:
2025    
2026         http://config.privoxy.org/show-version
2027        
2028   * Show the client's request headers:
2029    
2030         http://config.privoxy.org/show-request
2031        
2032   * Show which actions apply to a URL and why:
2033    
2034         http://config.privoxy.org/show-url-info
2035        
2036   * Toggle Privoxy on or off. In this case, "Privoxy" continues to run, but
2037     only as a pass-through proxy, with no actions taking place:
2038    
2039         http://config.privoxy.org/toggle
2040        
2041     Short cuts. Turn off, then on:
2042    
2043         http://config.privoxy.org/toggle?set=disable
2044        
2045         http://config.privoxy.org/toggle?set=enable
2046        
2047   * Edit the actions list file:
2048    
2049         http://config.privoxy.org/edit-actions
2050        
2051 These may be bookmarked for quick reference. 
2052
2053 -------------------------------------------------------------------------------
2054
2055 9.2.1. Bookmarklets
2056
2057 Below are some "bookmarklets" to allow you to easily access a "mini" version of
2058 some of Privoxy's special pages. They are designed for MS Internet Explorer,
2059 but should work equally well in Netscape, Mozilla, and other browsers which
2060 support JavaScript. They are designed to run directly from your bookmarks - not
2061 by clicking the links below (although that should work for testing).
2062
2063 To save them, right-click the link and choose "Add to Favorites" (IE) or "Add
2064 Bookmark" (Netscape). You will get a warning that the bookmark "may not be
2065 safe" - just click OK. Then you can run the Bookmarklet directly from your
2066 favourites/bookmarks. For even faster access, you can put them on the "Links"
2067 bar (IE) or the "Personal Toolbar" (Netscape), and run them with a single
2068 click.
2069
2070   * Enable Privoxy
2071    
2072   * Disable Privoxy
2073    
2074   * Toggle Privoxy (Toggles between enabled and disabled)
2075    
2076   * View Privoxy Status
2077    
2078   * Actions file feedback system
2079    
2080 Credit: The site which gave me the general idea for these bookmarklets is 
2081 www.bookmarklets.com. They have more information about bookmarklets.
2082
2083 -------------------------------------------------------------------------------
2084
2085 9.3. Anatomy of an Action
2086
2087 The way Privoxy applies "actions" and "filters" to any given URL can be
2088 complex, and not always so easy to understand what is happening. And sometimes
2089 we need to be able to see just what Privoxy is doing. Especially, if something
2090 Privoxy is doing is causing us a problem inadvertantly. It can be a little
2091 daunting to look at the actions and filters files themselves, since they tend
2092 to be filled with "regular expressions" whose consequences are not always so
2093 obvious. Privoxy provides the http://config.privoxy.org/show-url-info page that
2094 can show us very specifically how actions are being applied to any given URL.
2095 This is a big help for troubleshooting.
2096
2097 First, enter one URL (or partial URL) at the prompt, and then Privoxy will tell
2098 us how the current configuration will handle it. This will not help with
2099 filtering effects from the default.filter file! It also will not tell you about
2100 any other URLs that may be embedded within the URL you are testing. For
2101 instance, images such as ads are expressed as URLs within the raw page source
2102 of HTML pages. So you will only get info for the actual URL that is pasted into
2103 the prompt area -- not any sub-URLs. If you want to know about embedded URLs
2104 like ads, you will have to dig those out of the HTML source. Use your browser's
2105 "View Page Source" option for this. Or right click on the ad, and grab the URL.
2106
2107 Let's look at an example, google.com, one section at a time:
2108
2109  System default actions:                                                       
2110                                                                                
2111  { -add-header -block -deanimate-gifs -downgrade -fast-redirects -filter       
2112    -hide-forwarded -hide-from -hide-referer -hide-user-agent -image            
2113    -image-blocker -limit-connect -no-compression -no-cookies-keep              
2114    -no-cookies-read -no-cookies-set -no-popups -vanilla-wafer -wafer }         
2115                                                                                
2116                                                                                
2117
2118 This is the top section, and only tells us of the compiled in defaults. This is
2119 basically what Privoxy would do if there were not any "actions" defined, i.e.
2120 it does nothing. Every action is disabled. This is not particularly informative
2121 for our purposes here. OK, next section:
2122
2123  Matches for http://google.com:                                                
2124                                                                                
2125  { -add-header -block +deanimate-gifs -downgrade +fast-redirects               
2126    +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups}          
2127    +filter{webbugs} +filter{nimda} +filter{banners-by-size} +filter{hal}       
2128    +filter{fun} +hide-forwarded +hide-from{block} +hide-referer{forge}         
2129    -hide-user-agent -image +image-blocker{blank} +no-compression               
2130    +no-cookies-keep -no-cookies-read -no-cookies-set +no-popups                
2131    -vanilla-wafer -wafer }                                                     
2132    /                                                                           
2133                                                                                
2134  { -no-cookies-keep -no-cookies-read -no-cookies-set }                         
2135   .google.com                                                                  
2136                                                                                
2137  { -fast-redirects }                                                           
2138   .google.com                                                                  
2139                                                                                
2140                                                                                
2141
2142 This is much more informative, and tells us how we have defined our "actions",
2143 and which ones match for our example, "google.com". The first grouping shows
2144 our default settings, which would apply to all URLs. If you look at your
2145 "actions" file, this would be the section just below the "aliases" section near
2146 the top. This applies to all URLs as signified by the single forward slash -- "
2147 /".
2148
2149 These are the default actions we have enabled. But we can define additional
2150 actions that would be exceptions to these general rules, and then list specific
2151 URLs that these exceptions would apply to. Last match wins. Just below this
2152 then are two explict matches for ".google.com". The first is negating our
2153 various cookie blocking actions (i.e. we will allow cookies here). The second
2154 is allowing "fast-redirects". Note that there is a leading dot here --
2155 ".google.com". This will match any hosts and sub-domains, in the google.com
2156 domain also, such as "www.google.com". So, apparently, we have these actions
2157 defined somewhere in the lower part of our actions file, and "google.com" is
2158 referenced in these sections. 
2159
2160 And now we pull it altogether in the bottom section and summarize how Privoxy
2161 is appying all its "actions" to "google.com": 
2162
2163  Final results:                                                                
2164                                                                                
2165  -add-header -block -deanimate-gifs -downgrade -fast-redirects                 
2166  +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups}            
2167  +filter{webbugs} +filter{nimda} +filter{banners-by-size} +filter{hal}         
2168  +filter{fun} +hide-forwarded +hide-from{block} +hide-referer{forge}           
2169  -hide-user-agent -image +image-blocker{blank} -limit-connect +no-compression  
2170  -no-cookies-keep -no-cookies-read -no-cookies-set +no-popups -vanilla-wafer   
2171  -wafer                                                                        
2172                                                                                
2173                                                                                
2174
2175 Now another example, "ad.doubleclick.net":
2176
2177  { +block +image }                                                             
2178   .ad.doubleclick.net                                                          
2179                                                                                
2180  { +block +image }                                                             
2181   ad*.                                                                         
2182                                                                                
2183  { +block +image }                                                             
2184   .doubleclick.net                                                             
2185                                                                                
2186                                                                                
2187
2188 We'll just show the interesting part here, the explicit matches. It is matched
2189 three different times. Each as an "+block +image", which is the expanded form
2190 of one of our aliases that had been defined as: "+imageblock". ("Aliases" are
2191 defined in the first section of the actions file and typically used to combine
2192 more than one action.)
2193
2194 Any one of these would have done the trick and blocked this as an unwanted
2195 image. This is unnecessarily redundant since the last case effectively would
2196 also cover the first. No point in taking chances with these guys though ;-)
2197 Note that if you want an ad or obnoxious URL to be invisible, it should be
2198 defined as "ad.doubleclick.net" is done here -- as both a "+block" and an
2199 "+image". The custom alias "+imageblock" does this for us.
2200
2201 One last example. Let's try "http://www.rhapsodyk.net/adsl/HOWTO/". This one is
2202 giving us problems. We are getting a blank page. Hmmm...
2203
2204  Matches for http://www.rhapsodyk.net/adsl/HOWTO/:                             
2205                                                                                
2206  { -add-header -block +deanimate-gifs -downgrade +fast-redirects               
2207    +filter{html-annoyances} +filter{js-annoyances} +filter{no-popups}          
2208    +filter{webbugs} +filter{nimda} +filter{banners-by-size} +filter{hal}       
2209    +filter{fun} +hide-forwarded +hide-from{block} +hide-referer{forge}         
2210    -hide-user-agent -image +image-blocker{blank} +no-compression               
2211    +no-cookies-keep -no-cookies-read -no-cookies-set +no-popups                
2212    -vanilla-wafer -wafer }                                                     
2213    /                                                                           
2214                                                                                
2215  { +block +image }                                                             
2216   /ads                                                                         
2217                                                                                
2218                                                                                
2219
2220 Ooops, the "/adsl/" is matching "/ads"! But we did not want this at all! Now we
2221 see why we get the blank page. We could now add a new action below this that
2222 explictly does not block (-block) pages with "adsl". There are various ways to
2223 handle such exceptions. Example:
2224
2225  { -block }                                                                    
2226   /adsl                                                                        
2227                                                                                
2228                                                                                
2229
2230 Now the page displays ;-) Be sure to flush your browser's caches when making
2231 such changes. Or, try using Shift+Reload.
2232
2233 But now what about a situation where we get no explicit matches like we did
2234 with:
2235
2236  { -block }                                                                    
2237   /adsl                                                                        
2238                                                                                
2239                                                                                
2240
2241 That actually was very telling and pointed us quickly to where the problem was.
2242 If you don't get this kind of match, then it means one of the default rules in
2243 the first section is causing the problem. This would require some guesswork,
2244 and maybe a little trial and error to isolate the offending rule. One likely
2245 cause would be one of the "{+filter}" actions. Try adding the URL for the site
2246 to one of aliases that turn off "+filter":
2247
2248  {shop}                                                                        
2249  .quietpc.com                                                                  
2250  .worldpay.com   # for quietpc.com                                             
2251  .jungle.com                                                                   
2252  .scan.co.uk                                                                   
2253  .forbes.com                                                                   
2254                                                                                
2255                                                                                
2256
2257 "{shop}" is an "alias" that expands to "{ -filter -no-cookies -no-cookies-keep
2258 }". Or you could do your own exception to negate filtering: 
2259
2260  {-filter}                                                                     
2261  .forbes.com                                                                   
2262                                                                                
2263                                                                                
2264
2265 "{fragile}" is an alias that disables most actions. This can be used as a last
2266 resort for problem sites. Remember to flush caches! If this still does not
2267 work, you will have to go through the remaining actions one by one to find
2268 which one(s) is causing the problem.
2269