1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
2 "http://www.w3.org/TR/html4/loose.dtd">
6 <meta name="generator" content=
7 "HTML Tidy for Linux/x86 (vers 7 December 2008), see www.w3.org">
9 <title>Appendix</title>
10 <meta name="GENERATOR" content=
11 "Modular DocBook HTML Stylesheet Version 1.79">
12 <link rel="HOME" title="Privoxy 3.0.18 User Manual" href="index.html">
13 <link rel="PREVIOUS" title="See Also" href="seealso.html">
14 <link rel="STYLESHEET" type="text/css" href="../p_doc.css">
15 <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
16 <link rel="STYLESHEET" type="text/css" href="p_doc.css">
17 <style type="text/css">
19 background-color: #EEEEEE;
22 :link { color: #0000FF }
23 :visited { color: #840084 }
24 :active { color: #0000FF }
25 table.c3 {background-color: #E0E0E0}
26 span.c2 {font-style: italic}
27 hr.c1 {text-align: left}
32 <div class="NAVHEADER">
33 <table summary="Header navigation table" width="100%" border="0"
34 cellpadding="0" cellspacing="0">
36 <th colspan="3" align="center">Privoxy 3.0.18 User Manual</th>
40 <td width="10%" align="left" valign="bottom"><a href="seealso.html"
41 accesskey="P">Prev</a></td>
43 <td width="80%" align="center" valign="bottom"></td>
45 <td width="10%" align="right" valign="bottom"> </td>
48 <hr class="c1" width="100%">
52 <h1 class="SECT1"><a name="APPENDIX" id="APPENDIX">14. Appendix</a></h1>
55 <h2 class="SECT2"><a name="REGEX" id="REGEX">14.1. Regular
58 <p><span class="APPLICATION">Privoxy</span> uses Perl-style
59 <span class="QUOTE">"regular expressions"</span> in its <a href=
60 "actions-file.html">actions files</a> and <a href=
61 "filter-file.html">filter file</a>, through the <a href=
62 "http://www.pcre.org/" target="_top">PCRE</a> and <span class=
63 "APPLICATION">PCRS</span> libraries.</p>
65 <p>If you are reading this, you probably don't understand what
66 <span class="QUOTE">"regular expressions"</span> are, or what they can
67 do. So this will be a very brief introduction only. A full explanation
68 would require a <a href="http://www.oreilly.com/catalog/regex/" target=
69 "_top">book</a> ;-)</p>
71 <p>Regular expressions provide a language to describe patterns that can
72 be run against strings of characters (letter, numbers, etc), to see if
73 they match the string or not. The patterns are themselves (sometimes
74 complex) strings of literal characters, combined with wild-cards, and
75 other special characters, called meta-characters. The <span class=
76 "QUOTE">"meta-characters"</span> have special meanings and are used to
77 build complex patterns to be matched against. Perl Compatible Regular
78 Expressions are an especially convenient <span class=
79 "QUOTE">"dialect"</span> of the regular expression language.</p>
81 <p>To make a simple analogy, we do something similar when we use
82 wild-card characters when listing files with the <b class=
83 "COMMAND">dir</b> command in DOS. <tt class="LITERAL">*.*</tt> matches
84 all filenames. The <span class="QUOTE">"special"</span> character here
85 is the asterisk which matches any and all characters. We can be more
86 specific and use <tt class="LITERAL">?</tt> to match just individual
87 characters. So <span class="QUOTE">"dir file?.text"</span> would match
88 <span class="QUOTE">"file1.txt"</span>, <span class=
89 "QUOTE">"file2.txt"</span>, etc. We are pattern matching, using a
90 similar technique to <span class="QUOTE">"regular
91 expressions"</span>!</p>
93 <p>Regular expressions do essentially the same thing, but are much,
94 much more powerful. There are many more <span class="QUOTE">"special
95 characters"</span> and ways of building complex patterns however. Let's
96 look at a few of the common ones, and then some examples:</p>
101 <td><span class="emphasis EMPHASIS c2">.</span> - Matches any
102 single character, e.g. <span class="QUOTE">"a"</span>,
103 <span class="QUOTE">"A"</span>, <span class="QUOTE">"4"</span>,
104 <span class="QUOTE">":"</span>, or <span class=
105 "QUOTE">"@"</span>.</td>
113 <td><span class="emphasis EMPHASIS c2">?</span> - The preceding
114 character or expression is matched ZERO or ONE times.
123 <td><span class="emphasis EMPHASIS c2">+</span> - The preceding
124 character or expression is matched ONE or MORE times.</td>
132 <td><span class="emphasis EMPHASIS c2">*</span> - The preceding
133 character or expression is matched ZERO or MORE times.</td>
141 <td><span class="emphasis EMPHASIS c2">\</span> - The
142 <span class="QUOTE">"escape"</span> character denotes that the
143 following character should be taken literally. This is used where
144 one of the special characters (e.g. <span class=
145 "QUOTE">"."</span>) needs to be taken literally and not as a
146 special meta-character. Example: <span class=
147 "QUOTE">"example\.com"</span>, makes sure the period is
148 recognized only as a period (and not expanded to its
149 meta-character meaning of any single character).</td>
157 <td><span class="emphasis EMPHASIS c2">[ ]</span> - Characters
158 enclosed in brackets will be matched if any of the enclosed
159 characters are encountered. For instance, <span class=
160 "QUOTE">"[0-9]"</span> matches any numeric digit (zero through
161 nine). As an example, we can combine this with <span class=
162 "QUOTE">"+"</span> to match any digit one of more times:
163 <span class="QUOTE">"[0-9]+"</span>.</td>
171 <td><span class="emphasis EMPHASIS c2">( )</span> - parentheses
172 are used to group a sub-expression, or multiple
173 sub-expressions.</td>
181 <td><span class="emphasis EMPHASIS c2">|</span> - The
182 <span class="QUOTE">"bar"</span> character works like an
183 <span class="QUOTE">"or"</span> conditional statement. A match is
184 successful if the sub-expression on either side of <span class=
185 "QUOTE">"|"</span> matches. As an example: <span class=
186 "QUOTE">"/(this|that) example/"</span> uses grouping and the bar
187 character and would match either <span class="QUOTE">"this
188 example"</span> or <span class="QUOTE">"that example"</span>, and
194 <p>These are just some of the ones you are likely to use when matching
195 URLs with <span class="APPLICATION">Privoxy</span>, and is a long way
196 from a definitive list. This is enough to get us started with a few
197 simple examples which may be more illuminating:</p>
199 <p><span class="emphasis EMPHASIS c2"><tt class=
200 "LITERAL">/.*/banners/.*</tt></span> - A simple example that uses the
201 common combination of <span class="QUOTE">"."</span> and <span class=
202 "QUOTE">"*"</span> to denote any character, zero or more times. In
203 other words, any string at all. So we start with a literal forward
204 slash, then our regular expression pattern (<span class=
205 "QUOTE">".*"</span>) another literal forward slash, the string
206 <span class="QUOTE">"banners"</span>, another forward slash, and lastly
207 another <span class="QUOTE">".*"</span>. We are building a directory
208 path here. This will match any file with the path that has a directory
209 named <span class="QUOTE">"banners"</span> in it. The <span class=
210 "QUOTE">".*"</span> matches any characters, and this could conceivably
211 be more forward slashes, so it might expand into a much longer looking
212 path. For example, this could match: <span class=
213 "QUOTE">"/eye/hate/spammers/banners/annoy_me_please.gif"</span>, or
214 just <span class="QUOTE">"/banners/annoying.html"</span>, or almost an
215 infinite number of other possible combinations, just so it has
216 <span class="QUOTE">"banners"</span> in the path somewhere.</p>
218 <p>And now something a little more complex:</p>
220 <p><span class="emphasis EMPHASIS c2"><tt class=
221 "LITERAL">/.*/adv((er)?ts?|ertis(ing|ements?))?/</tt></span> - We have
222 several literal forward slashes again (<span class="QUOTE">"/"</span>),
223 so we are building another expression that is a file path statement. We
224 have another <span class="QUOTE">".*"</span>, so we are matching
225 against any conceivable sub-path, just so it matches our expression.
226 The only true literal that <span class="emphasis EMPHASIS c2">must
227 match</span> our pattern is <span class="APPLICATION">adv</span>,
228 together with the forward slashes. What comes after the <span class=
229 "QUOTE">"adv"</span> string is the interesting part.</p>
231 <p>Remember the <span class="QUOTE">"?"</span> means the preceding
232 expression (either a literal character or anything grouped with
233 <span class="QUOTE">"(...)"</span> in this case) can exist or not,
234 since this means either zero or one match. So <span class=
235 "QUOTE">"((er)?ts?|ertis(ing|ements?))"</span> is optional, as are the
236 individual sub-expressions: <span class="QUOTE">"(er)"</span>,
237 <span class="QUOTE">"(ing|ements?)"</span>, and the <span class=
238 "QUOTE">"s"</span>. The <span class="QUOTE">"|"</span> means
239 <span class="QUOTE">"or"</span>. We have two of those. For instance,
240 <span class="QUOTE">"(ing|ements?)"</span>, can expand to match either
241 <span class="QUOTE">"ing"</span> <span class=
242 "emphasis EMPHASIS c2">OR</span> <span class="QUOTE">"ements?"</span>.
243 What is being done here, is an attempt at matching as many variations
244 of <span class="QUOTE">"advertisement"</span>, and similar, as
245 possible. So this would expand to match just <span class=
246 "QUOTE">"adv"</span>, or <span class="QUOTE">"advert"</span>, or
247 <span class="QUOTE">"adverts"</span>, or <span class=
248 "QUOTE">"advertising"</span>, or <span class=
249 "QUOTE">"advertisement"</span>, or <span class=
250 "QUOTE">"advertisements"</span>. You get the idea. But it would not
251 match <span class="QUOTE">"advertizements"</span> (with a <span class=
252 "QUOTE">"z"</span>). We could fix that by changing our regular
253 expression to: <span class=
254 "QUOTE">"/.*/adv((er)?ts?|erti(s|z)(ing|ements?))?/"</span>, which
255 would then match either spelling.</p>
257 <p><span class="emphasis EMPHASIS c2"><tt class=
258 "LITERAL">/.*/advert[0-9]+\.(gif|jpe?g)</tt></span> - Again another
259 path statement with forward slashes. Anything in the square brackets
260 <span class="QUOTE">"[ ]"</span> can be matched. This is using
261 <span class="QUOTE">"0-9"</span> as a shorthand expression to mean any
262 digit one through nine. It is the same as saying <span class=
263 "QUOTE">"0123456789"</span>. So any digit matches. The <span class=
264 "QUOTE">"+"</span> means one or more of the preceding expression must
265 be included. The preceding expression here is what is in the square
266 brackets -- in this case, any digit one through nine. Then, at the end,
267 we have a grouping: <span class="QUOTE">"(gif|jpe?g)"</span>. This
268 includes a <span class="QUOTE">"|"</span>, so this needs to match the
269 expression on either side of that bar character also. A simple
270 <span class="QUOTE">"gif"</span> on one side, and the other side will
271 in turn match either <span class="QUOTE">"jpeg"</span> or <span class=
272 "QUOTE">"jpg"</span>, since the <span class="QUOTE">"?"</span> means
273 the letter <span class="QUOTE">"e"</span> is optional and can be
274 matched once or not at all. So we are building an expression here to
275 match image GIF or JPEG type image file. It must include the literal
276 string <span class="QUOTE">"advert"</span>, then one or more digits,
277 and a <span class="QUOTE">"."</span> (which is now a literal, and not a
278 special character, since it is escaped with <span class=
279 "QUOTE">"\"</span>), and lastly either <span class=
280 "QUOTE">"gif"</span>, or <span class="QUOTE">"jpeg"</span>, or
281 <span class="QUOTE">"jpg"</span>. Some possible matches would include:
282 <span class="QUOTE">"//advert1.jpg"</span>, <span class=
283 "QUOTE">"/nasty/ads/advert1234.gif"</span>, <span class=
284 "QUOTE">"/banners/from/hell/advert99.jpg"</span>. It would not match
285 <span class="QUOTE">"advert1.gif"</span> (no leading slash), or
286 <span class="QUOTE">"/adverts232.jpg"</span> (the expression does not
287 include an <span class="QUOTE">"s"</span>), or <span class=
288 "QUOTE">"/advert1.jsp"</span> (<span class="QUOTE">"jsp"</span> is not
289 in the expression anywhere).</p>
291 <p>We are barely scratching the surface of regular expressions here so
292 that you can understand the default <span class=
293 "APPLICATION">Privoxy</span> configuration files, and maybe use this
294 knowledge to customize your own installation. There is much, much more
295 that can be done with regular expressions. Now that you know enough to
296 get started, you can learn more on your own :/</p>
298 <p>More reading on Perl Compatible Regular expressions: <a href=
299 "http://perldoc.perl.org/perlre.html" target=
300 "_top">http://perldoc.perl.org/perlre.html</a></p>
302 <p>For information on regular expression based substitutions and their
303 applications in filters, please see the <a href=
304 "filter-file.html">filter file tutorial</a> in this manual.</p>
308 <h2 class="SECT2"><a name="AEN5773" id="AEN5773">14.2. Privoxy's
309 Internal Pages</a></h2>
311 <p>Since <span class="APPLICATION">Privoxy</span> proxies each
312 requested web page, it is easy for <span class=
313 "APPLICATION">Privoxy</span> to trap certain special URLs. In this way,
314 we can talk directly to <span class="APPLICATION">Privoxy</span>, and
315 see how it is configured, see how our rules are being applied, change
316 these rules and other configuration options, and even turn <span class=
317 "APPLICATION">Privoxy's</span> filtering off, all with a web
320 <p>The URLs listed below are the special ones that allow direct access
321 to <span class="APPLICATION">Privoxy</span>. Of course, <span class=
322 "APPLICATION">Privoxy</span> must be running to access these. If not,
323 you will get a friendly error message. Internet access is not necessary
328 <p>Privoxy main page:</p><a name="AEN5787" id="AEN5787"></a>
330 <blockquote class="BLOCKQUOTE">
331 <p><a href="http://config.privoxy.org/" target=
332 "_top">http://config.privoxy.org/</a></p>
335 <p>There is a shortcut: <a href="http://p.p/" target=
336 "_top">http://p.p/</a> (But it doesn't provide a fall-back to a
337 real page, in case the request is not sent through <span class=
338 "APPLICATION">Privoxy</span>)</p>
342 <p>Show information about the current configuration, including
343 viewing and editing of actions files:</p><a name="AEN5795" id=
346 <blockquote class="BLOCKQUOTE">
347 <p><a href="http://config.privoxy.org/show-status" target=
348 "_top">http://config.privoxy.org/show-status</a></p>
353 <p>Show the source code version numbers:</p><a name="AEN5800" id=
356 <blockquote class="BLOCKQUOTE">
357 <p><a href="http://config.privoxy.org/show-version" target=
358 "_top">http://config.privoxy.org/show-version</a></p>
363 <p>Show the browser's request headers:</p><a name="AEN5805" id=
366 <blockquote class="BLOCKQUOTE">
367 <p><a href="http://config.privoxy.org/show-request" target=
368 "_top">http://config.privoxy.org/show-request</a></p>
373 <p>Show which actions apply to a URL and why:</p><a name="AEN5810"
376 <blockquote class="BLOCKQUOTE">
377 <p><a href="http://config.privoxy.org/show-url-info" target=
378 "_top">http://config.privoxy.org/show-url-info</a></p>
383 <p>Toggle Privoxy on or off. This feature can be turned off/on in
384 the main <tt class="FILENAME">config</tt> file. When toggled
385 <span class="QUOTE">"off"</span>, <span class=
386 "QUOTE">"Privoxy"</span> continues to run, but only as a
387 pass-through proxy, with no actions taking place:</p><a name=
388 "AEN5818" id="AEN5818"></a>
390 <blockquote class="BLOCKQUOTE">
391 <p><a href="http://config.privoxy.org/toggle" target=
392 "_top">http://config.privoxy.org/toggle</a></p>
395 <p>Short cuts. Turn off, then on:</p><a name="AEN5822" id=
398 <blockquote class="BLOCKQUOTE">
399 <p><a href="http://config.privoxy.org/toggle?set=disable" target=
400 "_top">http://config.privoxy.org/toggle?set=disable</a></p>
401 </blockquote><a name="AEN5825" id="AEN5825"></a>
403 <blockquote class="BLOCKQUOTE">
404 <p><a href="http://config.privoxy.org/toggle?set=enable" target=
405 "_top">http://config.privoxy.org/toggle?set=enable</a></p>
410 <p>These may be bookmarked for quick reference. See next.</p>
413 <h3 class="SECT3"><a name="BOOKMARKLETS" id="BOOKMARKLETS">14.2.1.
414 Bookmarklets</a></h3>
416 <p>Below are some <span class="QUOTE">"bookmarklets"</span> to allow
417 you to easily access a <span class="QUOTE">"mini"</span> version of
418 some of <span class="APPLICATION">Privoxy's</span> special pages.
419 They are designed for MS Internet Explorer, but should work equally
420 well in Netscape, Mozilla, and other browsers which support
421 JavaScript. They are designed to run directly from your bookmarks -
422 not by clicking the links below (although that should work for
425 <p>To save them, right-click the link and choose <span class=
426 "QUOTE">"Add to Favorites"</span> (IE) or <span class="QUOTE">"Add
427 Bookmark"</span> (Netscape). You will get a warning that the bookmark
428 <span class="QUOTE">"may not be safe"</span> - just click OK. Then
429 you can run the Bookmarklet directly from your favorites/bookmarks.
430 For even faster access, you can put them on the <span class=
431 "QUOTE">"Links"</span> bar (IE) or the <span class="QUOTE">"Personal
432 Toolbar"</span> (Netscape), and run them with a single click.</p>
437 "javascript:void(window.open('http://config.privoxy.org/toggle?mini=y&set=enabled','ijbstatus','width=250,height=100,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
438 target="_top">Privoxy - Enable</a></p>
443 "javascript:void(window.open('http://config.privoxy.org/toggle?mini=y&set=disabled','ijbstatus','width=250,height=100,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
444 target="_top">Privoxy - Disable</a></p>
449 "javascript:void(window.open('http://config.privoxy.org/toggle?mini=y&set=toggle','ijbstatus','width=250,height=100,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
450 target="_top">Privoxy - Toggle Privoxy</a> (Toggles between
451 enabled and disabled)</p>
456 "javascript:void(window.open('http://config.privoxy.org/toggle?mini=y','ijbstatus','width=250,height=2,resizable=yes,scrollbars=no,toolbar=no,location=no,directories=no,status=no,menubar=no,copyhistory=no').focus());"
457 target="_top">Privoxy- View Status</a></p>
462 "javascript:void(window.open('http://config.privoxy.org/show-url-info?url='+escape(location.href),'Why').focus());"
463 target="_top">Privoxy - Why?</a></p>
467 <p>Credit: The site which gave us the general idea for these
468 bookmarklets is <a href="http://www.bookmarklets.com/" target=
469 "_top">www.bookmarklets.com</a>. They have more information about
475 <h2 class="SECT2"><a name="CHAIN" id="CHAIN">14.3. Chain of
478 <p>Let's take a quick look at how some of <span class=
479 "APPLICATION">Privoxy's</span> core features are triggered, and the
480 ensuing sequence of events when a web page is requested by your
485 <p>First, your web browser requests a web page. The browser knows
486 to send the request to <span class="APPLICATION">Privoxy</span>,
487 which will in turn, relay the request to the remote web server
488 after passing the following tests:</p>
492 <p><span class="APPLICATION">Privoxy</span> traps any request for
493 its own internal CGI pages (e.g <a href="http://p.p/" target=
494 "_top">http://p.p/</a>) and sends the CGI page back to the
499 <p>Next, <span class="APPLICATION">Privoxy</span> checks to see if
500 the URL matches any <a href="actions-file.html#BLOCK"><span class=
501 "QUOTE">"+block"</span></a> patterns. If so, the URL is then
502 blocked, and the remote web server will not be contacted. <a href=
503 "actions-file.html#HANDLE-AS-IMAGE"><span class=
504 "QUOTE">"+handle-as-image"</span></a> and <a href=
505 "actions-file.html#HANDLE-AS-EMPTY-DOCUMENT"><span class=
506 "QUOTE">"+handle-as-empty-document"</span></a> are then checked,
507 and if there is no match, an HTML <span class=
508 "QUOTE">"BLOCKED"</span> page is sent back to the browser.
509 Otherwise, if it does match, an image is returned for the former,
510 and an empty text document for the latter. The type of image would
511 depend on the setting of <a href=
512 "actions-file.html#SET-IMAGE-BLOCKER"><span class=
513 "QUOTE">"+set-image-blocker"</span></a> (blank, checkerboard
514 pattern, or an HTTP redirect to an image elsewhere).</p>
518 <p>Untrusted URLs are blocked. If URLs are being added to the
519 <tt class="FILENAME">trust</tt> file, then that is done.</p>
523 <p>If the URL pattern matches the <a href=
524 "actions-file.html#FAST-REDIRECTS"><span class=
525 "QUOTE">"+fast-redirects"</span></a> action, it is then processed.
526 Unwanted parts of the requested URL are stripped.</p>
530 <p>Now the rest of the client browser's request headers are
531 processed. If any of these match any of the relevant actions (e.g.
532 <a href="actions-file.html#HIDE-USER-AGENT"><span class=
533 "QUOTE">"+hide-user-agent"</span></a>, etc.), headers are
534 suppressed or forged as determined by these actions and their
539 <p>Now the web server starts sending its response back (i.e.
540 typically a web page).</p>
544 <p>First, the server headers are read and processed to determine,
545 among other things, the MIME type (document type) and encoding. The
546 headers are then filtered as determined by the <a href=
547 "actions-file.html#CRUNCH-INCOMING-COOKIES"><span class=
548 "QUOTE">"+crunch-incoming-cookies"</span></a>, <a href=
549 "actions-file.html#SESSION-COOKIES-ONLY"><span class=
550 "QUOTE">"+session-cookies-only"</span></a>, and <a href=
551 "actions-file.html#DOWNGRADE-HTTP-VERSION"><span class=
552 "QUOTE">"+downgrade-http-version"</span></a> actions.</p>
556 <p>If any <a href="actions-file.html#FILTER"><span class=
557 "QUOTE">"+filter"</span></a> action or <a href=
558 "actions-file.html#DEANIMATE-GIFS"><span class=
559 "QUOTE">"+deanimate-gifs"</span></a> action applies (and the
560 document type fits the action), the rest of the page is read into
561 memory (up to a configurable limit). Then the filter rules (from
562 <tt class="FILENAME">default.filter</tt> and any other filter
563 files) are processed against the buffered content. Filters are
564 applied in the order they are specified in one of the filter files.
565 Animated GIFs, if present, are reduced to either the first or last
566 frame, depending on the action setting.The entire page, which is
567 now filtered, is then sent by <span class=
568 "APPLICATION">Privoxy</span> back to your browser.</p>
570 <p>If neither a <a href="actions-file.html#FILTER"><span class=
571 "QUOTE">"+filter"</span></a> action or <a href=
572 "actions-file.html#DEANIMATE-GIFS"><span class=
573 "QUOTE">"+deanimate-gifs"</span></a> matches, then <span class=
574 "APPLICATION">Privoxy</span> passes the raw data through to the
575 client browser as it becomes available.</p>
579 <p>As the browser receives the now (possibly filtered) page
580 content, it reads and then requests any URLs that may be embedded
581 within the page source, e.g. ad images, stylesheets, JavaScript,
582 other HTML documents (e.g. frames), sounds, etc. For each of these
583 objects, the browser issues a separate request (this is easily
584 viewable in <span class="APPLICATION">Privoxy's</span> logs). And
585 each such request is in turn processed just as above. Note that a
586 complex web page will have many, many such embedded URLs. If these
587 secondary requests are to a different server, then quite possibly a
588 very differing set of actions is triggered.</p>
592 <p>NOTE: This is somewhat of a simplistic overview of what happens with
593 each URL request. For the sake of brevity and simplicity, we have
594 focused on <span class="APPLICATION">Privoxy's</span> core features
599 <h2 class="SECT2"><a name="ACTIONSANAT" id="ACTIONSANAT">14.4.
600 Troubleshooting: Anatomy of an Action</a></h2>
602 <p>The way <span class="APPLICATION">Privoxy</span> applies <a href=
603 "actions-file.html#ACTIONS">actions</a> and <a href=
604 "actions-file.html#FILTER">filters</a> to any given URL can be complex,
605 and not always so easy to understand what is happening. And sometimes
606 we need to be able to <span class="emphasis EMPHASIS c2">see</span>
607 just what <span class="APPLICATION">Privoxy</span> is doing.
608 Especially, if something <span class="APPLICATION">Privoxy</span> is
609 doing is causing us a problem inadvertently. It can be a little
610 daunting to look at the actions and filters files themselves, since
611 they tend to be filled with <a href="appendix.html#REGEX">regular
612 expressions</a> whose consequences are not always so obvious.</p>
614 <p>One quick test to see if <span class="APPLICATION">Privoxy</span> is
615 causing a problem or not, is to disable it temporarily. This should be
616 the first troubleshooting step. See <a href=
617 "appendix.html#BOOKMARKLETS">the Bookmarklets</a> section on a quick
618 and easy way to do this (be sure to flush caches afterward!). Looking
619 at the logs is a good idea too. (Note that both the toggle feature and
620 logging are enabled via <tt class="FILENAME">config</tt> file settings,
621 and may need to be turned <span class="QUOTE">"on"</span>.)</p>
623 <p>Another easy troubleshooting step to try is if you have done any
624 customization of your installation, revert back to the installed
625 defaults and see if that helps. There are times the developers get
626 complaints about one thing or another, and the problem is more related
627 to a customized configuration issue.</p>
629 <p><span class="APPLICATION">Privoxy</span> also provides the <a href=
630 "http://config.privoxy.org/show-url-info" target=
631 "_top">http://config.privoxy.org/show-url-info</a> page that can show
632 us very specifically how <span class="APPLICATION">actions</span> are
633 being applied to any given URL. This is a big help for
636 <p>First, enter one URL (or partial URL) at the prompt, and then
637 <span class="APPLICATION">Privoxy</span> will tell us how the current
638 configuration will handle it. This will not help with filtering effects
639 (i.e. the <a href="actions-file.html#FILTER"><span class=
640 "QUOTE">"+filter"</span></a> action) from one of the filter files since
641 this is handled very differently and not so easy to trap! It also will
642 not tell you about any other URLs that may be embedded within the URL
643 you are testing. For instance, images such as ads are expressed as URLs
644 within the raw page source of HTML pages. So you will only get info for
645 the actual URL that is pasted into the prompt area -- not any sub-URLs.
646 If you want to know about embedded URLs like ads, you will have to dig
647 those out of the HTML source. Use your browser's <span class=
648 "QUOTE">"View Page Source"</span> option for this. Or right click on
649 the ad, and grab the URL.</p>
651 <p>Let's try an example, <a href="http://google.com" target=
652 "_top">google.com</a>, and look at it one section at a time in a sample
653 configuration (your real configuration may vary):</p>
655 <table class="c3" border="0" width="100%">
659 Matches for http://www.google.com:
661 In file: default.action <span class="GUIBUTTON">[ View ]</span> <span class=
662 "GUIBUTTON">[ Edit ]</span>
664 {+change-x-forwarded-for{block}
665 +deanimate-gifs {last}
666 +fast-redirects {check-decoded-url}
667 +filter {refresh-tags}
668 +filter {img-reorder}
669 +filter {banners-by-size}
671 +filter {jumping-windows}
672 +filter {ie-exploits}
673 +hide-from-header {block}
674 +hide-referrer {forge}
675 +session-cookies-only
676 +set-image-blocker {pattern}
679 { -session-cookies-only }
685 In file: user.action <span class="GUIBUTTON">[ View ]</span> <span class=
686 "GUIBUTTON">[ Edit ]</span>
687 (no matches in this file)
693 <p>This is telling us how we have defined our <a href=
694 "actions-file.html#ACTIONS"><span class="QUOTE">"actions"</span></a>,
695 and which ones match for our test case, <span class=
696 "QUOTE">"google.com"</span>. Displayed is all the actions that are
697 available to us. Remember, the <tt class="LITERAL">+</tt> sign denotes
698 <span class="QUOTE">"on"</span>. <tt class="LITERAL">-</tt> denotes
699 <span class="QUOTE">"off"</span>. So some are <span class=
700 "QUOTE">"on"</span> here, but many are <span class=
701 "QUOTE">"off"</span>. Each example we try may provide a slightly
702 different end result, depending on our configuration directives.</p>
704 <p>The first listing is for our <tt class=
705 "FILENAME">default.action</tt> file. The large, multi-line listing, is
706 how the actions are set to match for all URLs, i.e. our default
707 settings. If you look at your <span class="QUOTE">"actions"</span>
708 file, this would be the section just below the <span class=
709 "QUOTE">"aliases"</span> section near the top. This will apply to all
710 URLs as signified by the single forward slash at the end of the listing
711 -- <span class="QUOTE">" / "</span>.</p>
713 <p>But we have defined additional actions that would be exceptions to
714 these general rules, and then we list specific URLs (or patterns) that
715 these exceptions would apply to. Last match wins. Just below this then
716 are two explicit matches for <span class="QUOTE">".google.com"</span>.
717 The first is negating our previous cookie setting, which was for
718 <a href="actions-file.html#SESSION-COOKIES-ONLY"><span class=
719 "QUOTE">"+session-cookies-only"</span></a> (i.e. not persistent). So we
720 will allow persistent cookies for google, at least that is how it is in
721 this example. The second turns <span class=
722 "emphasis EMPHASIS c2">off</span> any <a href=
723 "actions-file.html#FAST-REDIRECTS"><span class=
724 "QUOTE">"+fast-redirects"</span></a> action, allowing this to take
725 place unmolested. Note that there is a leading dot here -- <span class=
726 "QUOTE">".google.com"</span>. This will match any hosts and
727 sub-domains, in the google.com domain also, such as <span class=
728 "QUOTE">"www.google.com"</span> or <span class=
729 "QUOTE">"mail.google.com"</span>. But it would not match <span class=
730 "QUOTE">"www.google.de"</span>! So, apparently, we have these two
731 actions defined as exceptions to the general rules at the top somewhere
732 in the lower part of our <tt class="FILENAME">default.action</tt> file,
733 and <span class="QUOTE">"google.com"</span> is referenced somewhere in
734 these latter sections.</p>
736 <p>Then, for our <tt class="FILENAME">user.action</tt> file, we again
737 have no hits. So there is nothing google-specific that we might have
738 added to our own, local configuration. If there was, those actions
739 would over-rule any actions from previously processed files, such as
740 <tt class="FILENAME">default.action</tt>. <tt class=
741 "FILENAME">user.action</tt> typically has the last word. This is the
742 best place to put hard and fast exceptions,</p>
744 <p>And finally we pull it all together in the bottom section and
745 summarize how <span class="APPLICATION">Privoxy</span> is applying all
746 its <span class="QUOTE">"actions"</span> to <span class=
747 "QUOTE">"google.com"</span>:</p>
749 <table class="c3" border="0" width="100%">
757 +change-x-forwarded-for{block}
758 -client-header-filter{hide-tor-exit-notation}
759 -content-type-overwrite
760 -crunch-client-header
761 -crunch-if-none-match
762 -crunch-incoming-cookies
763 -crunch-outgoing-cookies
764 -crunch-server-header
765 +deanimate-gifs {last}
766 -downgrade-http-version
769 -filter {content-cookies}
771 -filter {banners-by-link}
772 -filter {tiny-textforms}
773 -filter {frameset-borders}
774 -filter {demoronizer}
775 -filter {shockwave-flash}
776 -filter {quicktime-kioskmode}
778 -filter {crude-parental}
779 -filter {site-specifics}
780 -filter {js-annoyances}
781 -filter {html-annoyances}
782 +filter {refresh-tags}
783 -filter {unsolicited-popups}
784 +filter {img-reorder}
785 +filter {banners-by-size}
787 +filter {jumping-windows}
788 +filter {ie-exploits}
795 -handle-as-empty-document
797 -hide-accept-language
798 -hide-content-disposition
799 +hide-from-header {block}
800 -hide-if-modified-since
801 +hide-referrer {forge}
804 -overwrite-last-modified
807 -server-header-filter{xml-to-html}
808 -server-header-filter{html-to-xml}
809 -session-cookies-only
810 +set-image-blocker {pattern}
816 <p>Notice the only difference here to the previous listing, is to
817 <span class="QUOTE">"fast-redirects"</span> and <span class=
818 "QUOTE">"session-cookies-only"</span>, which are activated specifically
819 for this site in our configuration, and thus show in the <span class=
820 "QUOTE">"Final Results"</span>.</p>
822 <p>Now another example, <span class=
823 "QUOTE">"ad.doubleclick.net"</span>:</p>
825 <table class="c3" border="0" width="100%">
829 { +block{Domains starts with "ad"} }
832 { +block{Domain contains "ad"} }
835 { +block{Doubleclick banner server} +handle-as-image }
836 .[a-vx-z]*.doubleclick.net
842 <p>We'll just show the interesting part here - the explicit matches. It
843 is matched three different times. Two <span class=
844 "QUOTE">"+block{}"</span> sections, and a <span class="QUOTE">"+block{}
845 +handle-as-image"</span>, which is the expanded form of one of our
846 aliases that had been defined as: <span class=
847 "QUOTE">"+block-as-image"</span>. (<a href=
848 "actions-file.html#ALIASES"><span class="QUOTE">"Aliases"</span></a>
849 are defined in the first section of the actions file and typically used
850 to combine more than one action.)</p>
852 <p>Any one of these would have done the trick and blocked this as an
853 unwanted image. This is unnecessarily redundant since the last case
854 effectively would also cover the first. No point in taking chances with
855 these guys though ;-) Note that if you want an ad or obnoxious URL to
856 be invisible, it should be defined as <span class=
857 "QUOTE">"ad.doubleclick.net"</span> is done here -- as both a <a href=
858 "actions-file.html#BLOCK"><span class="QUOTE">"+block{}"</span></a>
859 <span class="emphasis EMPHASIS c2">and</span> an <a href=
860 "actions-file.html#HANDLE-AS-IMAGE"><span class=
861 "QUOTE">"+handle-as-image"</span></a>. The custom alias <span class=
862 "QUOTE">"<tt class="LITERAL">+block-as-image</tt>"</span> just
863 simplifies the process and make it more readable.</p>
865 <p>One last example. Let's try <span class=
866 "QUOTE">"http://www.example.net/adsl/HOWTO/"</span>. This one is giving
867 us problems. We are getting a blank page. Hmmm ...</p>
869 <table class="c3" border="0" width="100%">
873 Matches for http://www.example.net/adsl/HOWTO/:
875 In file: default.action <span class="GUIBUTTON">[ View ]</span> <span class=
876 "GUIBUTTON">[ Edit ]</span>
880 +change-x-forwarded-for{block}
881 -client-header-filter{hide-tor-exit-notation}
882 -content-type-overwrite
883 -crunch-client-header
884 -crunch-if-none-match
885 -crunch-incoming-cookies
886 -crunch-outgoing-cookies
887 -crunch-server-header
889 -downgrade-http-version
890 +fast-redirects {check-decoded-url}
892 -filter {content-cookies}
894 -filter {banners-by-link}
895 -filter {tiny-textforms}
896 -filter {frameset-borders}
897 -filter {demoronizer}
898 -filter {shockwave-flash}
899 -filter {quicktime-kioskmode}
901 -filter {crude-parental}
902 -filter {site-specifics}
903 -filter {js-annoyances}
904 -filter {html-annoyances}
905 +filter {refresh-tags}
906 -filter {unsolicited-popups}
907 +filter {img-reorder}
908 +filter {banners-by-size}
910 +filter {jumping-windows}
911 +filter {ie-exploits}
918 -handle-as-empty-document
920 -hide-accept-language
921 -hide-content-disposition
922 +hide-from-header{block}
925 -overwrite-last-modified
928 -server-header-filter{xml-to-html}
929 -server-header-filter{html-to-xml}
930 +session-cookies-only
931 +set-image-blocker{blank} }
934 { +block{Path contains "ads".} +handle-as-image }
941 <p>Ooops, the <span class="QUOTE">"/adsl/"</span> is matching
942 <span class="QUOTE">"/ads"</span> in our configuration! But we did not
943 want this at all! Now we see why we get the blank page. It is actually
944 triggering two different actions here, and the effects are aggregated
945 so that the URL is blocked, and <span class=
946 "APPLICATION">Privoxy</span> is told to treat the block as if it were
947 an image. But this is, of course, all wrong. We could now add a new
948 action below this (or better in our own <tt class=
949 "FILENAME">user.action</tt> file) that explicitly <span class=
950 "emphasis EMPHASIS c2">un</span> blocks ( <a href=
951 "actions-file.html#BLOCK"><span class="QUOTE">"{-block}"</span></a>)
952 paths with <span class="QUOTE">"adsl"</span> in them (remember, last
953 match in the configuration wins). There are various ways to handle such
954 exceptions. Example:</p>
956 <table class="c3" border="0" width="100%">
967 <p>Now the page displays ;-) Remember to flush your browser's caches
968 when making these kinds of changes to your configuration to insure that
969 you get a freshly delivered page! Or, try using <tt class=
970 "LITERAL">Shift+Reload</tt>.</p>
972 <p>But now what about a situation where we get no explicit matches like
975 <table class="c3" border="0" width="100%">
979 { +block{Path starts with "ads".} +handle-as-image }
986 <p>That actually was very helpful and pointed us quickly to where the
987 problem was. If you don't get this kind of match, then it means one of
988 the default rules in the first section of <tt class=
989 "FILENAME">default.action</tt> is causing the problem. This would
990 require some guesswork, and maybe a little trial and error to isolate
991 the offending rule. One likely cause would be one of the <a href=
992 "actions-file.html#FILTER"><span class="QUOTE">"+filter"</span></a>
993 actions. These tend to be harder to troubleshoot. Try adding the URL
994 for the site to one of aliases that turn off <a href=
995 "actions-file.html#FILTER"><span class=
996 "QUOTE">"+filter"</span></a>:</p>
998 <table class="c3" border="0" width="100%">
1001 <pre class="SCREEN">
1004 .worldpay.com # for quietpc.com
1013 <p><span class="QUOTE">"<tt class="LITERAL">{ shop }</tt>"</span> is an
1014 <span class="QUOTE">"alias"</span> that expands to <span class=
1015 "QUOTE">"<tt class="LITERAL">{ -filter -session-cookies-only
1016 }</tt>"</span>. Or you could do your own exception to negate
1019 <table class="c3" border="0" width="100%">
1022 <pre class="SCREEN">
1024 # Disable ALL filter actions for sites in this section
1033 <p>This would turn off all filtering for these sites. This is best put
1034 in <tt class="FILENAME">user.action</tt>, for local site exceptions.
1035 Note that when a simple domain pattern is used by itself (without the
1036 subsequent path portion), all sub-pages within that domain are included
1037 automatically in the scope of the action.</p>
1039 <p>Images that are inexplicably being blocked, may well be hitting the
1040 <a href="actions-file.html#FILTER-BANNERS-BY-SIZE"><span class=
1041 "QUOTE">"+filter{banners-by-size}"</span></a> rule, which assumes that
1042 images of certain sizes are ad banners (works well <span class=
1043 "emphasis EMPHASIS c2">most of the time</span> since these tend to be
1046 <p><span class="QUOTE">"<tt class="LITERAL">{ fragile }</tt>"</span> is
1047 an alias that disables most actions that are the most likely to cause
1048 trouble. This can be used as a last resort for problem sites.</p>
1050 <table class="c3" border="0" width="100%">
1053 <pre class="SCREEN">
1055 # Handle with care: easy to break
1063 <p><span class="emphasis EMPHASIS c2">Remember to flush caches!</span>
1064 Note that the <tt class="LITERAL">mail.google</tt> reference lacks the
1065 TLD portion (e.g. <span class="QUOTE">".com"</span>). This will
1066 effectively match any TLD with <tt class="LITERAL">google</tt> in it,
1067 such as <tt class="LITERAL">mail.google.de.</tt>, just as an
1070 <p>If this still does not work, you will have to go through the
1071 remaining actions one by one to find which one(s) is causing the
1076 <div class="NAVFOOTER">
1077 <hr class="c1" width="100%">
1079 <table summary="Footer navigation table" width="100%" border="0"
1080 cellpadding="0" cellspacing="0">
1082 <td width="33%" align="left" valign="top"><a href="seealso.html"
1083 accesskey="P">Prev</a></td>
1085 <td width="34%" align="center" valign="top"><a href="index.html"
1086 accesskey="H">Home</a></td>
1088 <td width="33%" align="right" valign="top"> </td>
1092 <td width="33%" align="left" valign="top">See Also</td>
1094 <td width="34%" align="center" valign="top"> </td>
1096 <td width="33%" align="right" valign="top"> </td>