Material fixes as pointed out by Ashley Sanders. Mention SRU rather than
[yazproxy-moved-to-github.git] / doc / reference.xml
1  <chapter id="proxy-reference">
2   <title>Proxy Reference</title>
3   <section id="proxy-operation">
4    <title>Operating Environment</title>
5    <para>
6     The YAZ proxy is a console program. After startup it spawns 
7     a child process (except on Windows or if option -X is given). 
8     The child process is the core of the proxy and it handles all
9     communication with clients and servers. The parent process
10     will restart the child process if it dies unexpectedly and report
11     the reason. For options for YAZ proxy,
12     see <xref linkend="proxy-usage"/>.
13    </para>
14    <para>
15     As an option, the proxy may change user identity to a less privileged
16     user.
17    </para>
18   </section>
19   <section id="proxy-target">
20    <title>Choosing the Backend Server</title>
21    <para>
22     When the proxy receives a Z39.50 Initialize Request from a Z39.50
23     client, it determines the backend server by the following rules:
24     <orderedlist>
25      <listitem>
26       <para>If the <literal>InitializeRequest</literal> PDU from the
27        client includes an 
28        <link linkend="otherinfo-encoding"><literal>otherInfo</literal></link>
29        element with OID
30        <literal>1.2.840.10003.10.1000.81.1</literal>, then the
31        contents of that element specify the server to be used, in the
32        usual YAZ address format (typically
33        <literal>tcp:<parameter>hostname</parameter>:<parameter>port</parameter></literal>)
34        as described in
35        <ulink url="&url.yaz.comstack.addresses;"
36         >the Addresses section of the YAZ manual</ulink>.
37       </para>
38      </listitem>
39
40      <listitem>
41       <para>Otherwise, the Proxy uses the default server, if one was
42        specified in the proxy configuration file. See
43        <xref linkend="proxy-config-target"/>.
44       </para>
45      </listitem>
46
47      <listitem>
48       <para>Otherwise, the Proxy uses the default server, if one was
49        specified on the command-line with the <literal>-t</literal>
50        option.
51       </para>
52      </listitem>
53      <listitem>
54       <para>Otherwise, the proxy closes the connection with
55        the client.
56       </para>
57      </listitem>
58     </orderedlist>
59    </para>
60    <para>
61     If the proxy receives an SRU request, the following rules are used.
62     <orderedlist>
63      <listitem>
64       <para>If default target has Explain information with a
65        <literal>database</literal> that matches the path of the
66        HTTP request of SRU that backend server is used for SRU operation.
67       </para>
68      </listitem>
69      <listitem>
70       <para>
71        Otherwise the service will return HTTP 404 (Not found).
72       </para>
73      </listitem>
74     </orderedlist>
75    </para>
76   </section>
77   <section id="proxy-keepalive">
78    <title>Keep-alive Facility</title>
79    <para>
80     The keep-alive is a facility where the proxy keeps the connection to the
81     backend server - even if the client closes the connection to the proxy.
82    </para>
83    <para>
84     If a new or another client connects to the proxy again and requests the
85     same backend it will be reassigned to this backend. In this case, the
86     proxy sends an initialize response directly to the client and an
87     initialize handshake with the backend is omitted.
88    </para>
89    <para>
90     When a client reconnects, query and record caching works better, if the
91     proxy assigns it to the same backend as before. And the result set
92     (if any) is re-used. To achieve this, Index Data defined a session
93     cookie which identifies the backend session.
94    </para>
95    <para>
96     The cookie is defined by the client and is sent as part of the
97     Initialize Request and passed in an
98     <link linkend="otherinfo-encoding"><literal>otherInfo</literal></link>
99     element with OID <literal>1.2.840.10003.10.1000.81.2</literal>.
100    </para>
101    <para>
102     Clients that do not send a cookie as part of the initialize request
103     may still better performance, since the init handshake is saved.
104    </para>
105    <para>
106     Refer to <xref linkend="proxy-config-keepalive"/> on how to setup
107     configuration parameters for keepalive.
108     </para>
109   </section>
110   
111   
112   <section id="query-cache">
113    <title>Query Caching</title>
114    <para>
115     Simple stateless clients often send identical Z39.50 searches
116     in a relatively short period of time (e.g. in order to produce a
117     results-list page, the next page,
118     a single full-record, etc). And for many targets, it's
119     much more expensive to produce a new result set than to
120     reuse an existing one.
121    </para>
122    <para>
123     The proxy tries to solve that by remembering the last query for each
124     backend target, so that if an identical query is received next, it
125     is turned into Present Requests rather than new Search Requests.
126    </para>
127    <note>
128     <para>
129      In a future we release will will probably allows for
130      an arbitrary-sized cache for targets supporting named result sets.
131     </para>
132    </note>
133    <para>
134     You can enable/disable query caching using option -o.
135    </para>
136   </section>
137   
138   <section id="record-cache">
139    <title>Record Caching</title>
140    <para>
141     As an option, the proxy may also cache result set records for the
142     last search.
143     The proxy takes into account the Record Syntax and CompSpec.
144     The CompSpec includes simple element set names as well.
145     By default the cache is 200000 bytes per session.
146    </para>
147   </section>
148   
149   <section id="query-validation">
150    <title>Query Validation</title>
151    <para>
152     The Proxy may also be configured to trap particular attributes in
153     Type-1 queries and send Bib-1 diagnostics back to the client without
154     even consulting the backend target. This facility may be useful if
155     a target does not properly issue diagnostics when unsupported attributes
156     are send to it.
157    </para>
158   </section>
159   
160    <section id="record-validation">
161    <title>Record Syntax Validation</title>
162    <para>
163     The proxy may be configured to accept, reject or convert records.
164     When accepted, the target passes search/present requests to the
165     backend target under the assumption that the target can honor the
166     request (In fact it may not do that). When a record is rejected because
167     the record syntax is "unsupported" the proxy returns a diagnostic to the
168     client. Finally, the proxy may convert records.
169    </para>
170    <para>
171     The proxy can convert from MARC to MARCXML and thereby offer an
172     XML version of any MARC record as long as it is ISO2709 encoded.
173     If the proxy is compiled with libXSLT support it can also
174     perform XSLT on XML.
175    </para>
176   </section>
177   
178   <section id="other-optimizations">
179    <title>Other Optimizations</title>
180    <para>
181     We've had some plans to support global caching of result set records,
182     but this has not yet been implemented.
183    </para>
184   </section>
185    
186   <section id="proxy-config-file">
187    <title>Proxy Configuration File</title>
188    <para>
189     The Proxy may read a configuration file using option
190     <literal>-c</literal> followed by the filename of a config file.
191    </para>
192    <para>
193     The config file is XML based. The YAZ proxy must be compiled 
194     with <ulink url="&url.libxml2;">libxml2</ulink> and
195     <ulink url="&url.libxslt;">libXSLT</ulink> support in
196     order for the config file facility to be enabled.
197    </para>
198    <para>
199     See <xref linkend="yazproxy-schema"/> for an XML schema
200     for the configuration.
201    </para>
202    <tip>
203     <para>To check for a config file to be well-formed, the yazproxy may
204      be invoked without specifying a listening port, i.e.
205      <screen>
206       yazproxy -c myconfig.xml
207      </screen>
208      If this does not produce errors, the file is well-formed.
209     </para>
210    </tip>
211    <section id="proxy-config-header">
212     <title>Proxy Configuration Header</title>
213     <para>
214      The proxy config file must have a root element called
215      <literal>proxy</literal> and scoped within namespace
216      <literal> xmlns="http://indexdata.dk/yazproxy/schema/0.9/</literal>.
217      All information except an optional XML header must be stored
218      within the <literal>proxy</literal> element.
219     </para>
220     <screen>
221      &lt;?xml version="1.0"?>
222      &lt;proxy xmlns="http://indexdata.dk/yazproxy/schema/0.9/">
223       &lt;!-- content here .. -->
224      &lt;/proxy>
225     </screen>
226    </section>
227    <section id="proxy-config-target">
228     <title>target</title>
229     <para>
230      The element <literal>target</literal> which may be repeated zero
231      or more times with parent element <literal>proxy</literal> contains
232      information about each backend target.
233      The <literal>target</literal> element have two attributes:
234      <literal>name</literal> which holds the logical name of the backend
235      target (required) and <literal>default</literal> (optional) which
236      (when given) specifies that the backend target is the default target -
237      equivalent to command line option <literal>-t</literal>.
238     </para>
239     <para>
240      <screen>
241      &lt;?xml version="1.0"?>
242      &lt;proxy xmlns="http://indexdata.dk/yazproxy/schema/0.9/">
243       &lt;target name="server1" default="1">
244        &lt;!-- description of server1 .. -->
245       &lt;/target>
246       &lt;target name="server2">
247        &lt;!-- description of server2 .. -->
248       &lt;/target>
249      &lt;/proxy>
250      </screen>
251     </para>
252    </section>
253    <section id="proxy-config-url">
254     <title>url</title>
255     <para>
256      The <literal>url</literal> which may be repeated one or more times
257      should be the child of the <literal>target</literal> element.
258      The CDATA of <literal>url</literal> is the Z-URL of the backend.
259     </para>
260     <para>
261      Multiple <literal>url</literal> element may be used. In that case, then
262      a client initiates a session, the proxy chooses the URL with the lowest
263      number of active sessions, thereby distributing the load. It is
264      assumed that each URL represents the same database (data).
265     </para>
266    </section>
267
268    <section id="proxy-config-target-timeout">
269     <title>target-timeout</title>
270     <para>
271      The element <literal>target-timeout</literal> is the child of element
272      <literal>target</literal> and specifies the amount in seconds before
273      a target session is shut down.
274     </para>
275     <para>
276      This can also be specified on the command line by using option
277      <literal>-T</literal>. Refer to OPTIONS in <xref linkend="proxy-usage"/>.
278     </para>
279    </section>
280
281    <section id="proxy-config-client-timeout">
282     <title>client-timeout</title>
283     <para>
284      The element <literal>client-timeout</literal> is the child of element
285      <literal>target</literal> and specifies the amount in seconds before
286      a client session is shut down.
287      </para>
288     <para>
289      This can also be specified on the command line by using option
290      <literal>-i</literal>.  Refer to OPTIONS in <xref linkend="proxy-usage"/>.
291     </para>
292    </section>
293
294    <section id="proxy-config-keepalive">
295     <title>keepalive</title>
296     <para>The <literal>keepalive</literal> element holds information about
297      the keepalive Z39.50 sessions. Keepalive sessions are proxy-to-backend
298      sessions that is no longer associated with a client session.
299     </para>
300     <para>The <literal>keepalive</literal> element which is the child of
301      the <literal>target</literal>holds two elements:
302      <literal>bandwidth</literal> and <literal>pdu</literal>.
303      The <literal>bandwidth</literal> is the maximum total bytes
304      transferred to/from the target. If a target session exceeds this
305      limit, it is shut down (and no longer kept alive). 
306      The <literal>pdu</literal> is the maximum number of requests sent
307      to the target. If a target session exceeds this limit, it is
308      shut down. The idea of these two limits is that avoid very long
309      sessions that use resources in a backend (that leaks!).
310     </para>
311     <para>
312      The following sets maximum number of bytes transferred in a
313      target session to 1 MB and maximum of requests to 400.
314      <screen>
315       &lt;keepalive>
316        &lt;bandwidth>1048576&lt;/bandwidth>
317        &lt;pdu>400&lt;/pdu>
318       &lt;/keepalive>
319      </screen>
320     </para>
321    </section>
322    <section id="proxy-config-limit">
323     <title>limit</title>
324     <para>
325      The <literal>limit</literal> section specifies bandwidth/pdu requests
326      limits for an active session.
327      The proxy records bandwidth/pdu requests during the last 60 seconds
328      (1 minute). The <literal>limit</literal> may include the
329      elements <literal>bandwidth</literal>, <literal>pdu</literal>,
330      <literal>retrieve</literal> and <literal>search</literal>.
331      The <literal>bandwidth</literal>
332      measures the number of bytes transferred within the last minute.
333      The <literal>pdu</literal> is the number of requests in the last
334      minute. The <literal>retrieve</literal> holds the maximum records to
335      which may be retrieved in one Present Request.
336      The <literal>search</literal> is the maximum number of searches
337      within the last minute.
338     </para>
339     <para>
340      If a bandwidth/pdu/search limit is reached the proxy will postpone the
341      requests to the target and wait one or more seconds. The idea of the
342      limit is to ensure that clients that downloads hundreds or thousands of
343      records do not hurt other users.
344     </para>
345     <para>
346      The following sets maximum number of bytes transferred per minute to
347      500Kbytes, maximum number of records retrievals to 40
348      and maximum number of searches to 20.
349      <screen>
350       &lt;limit>
351        &lt;bandwidth>524288&lt;/bandwidth>
352        &lt;retrieve>40&lt;/retrieve>
353        &lt;search>20&lt;/search>
354       &lt;/limit>
355      </screen>
356     </para>
357     <note>
358      <para>
359       Typically the values in the keepalive section are mugh higher
360       than their equivalent limit counterparts (bandwidth, pdu).
361      </para>
362     </note>
363    </section>
364    
365    <section id="proxy-config-attribute">
366     <title>attribute</title>
367     <para>
368      The <literal>attribute</literal> element specifies accept or reject
369      or a particular attribute type, value pair.
370      Well-behaving targets will reject unsupported attributes on their
371      own. This feature is useful for targets that do not gracefully
372      handle unsupported attributes.
373     </para>
374     <para>
375      Attribute elements may be repeated. The proxy inspects the attribute
376      specifications in the order as specified in the configuration file.
377      When a given attribute specification matches a given attribute list
378      in a query, the proxy takes appropriate action (reject, accept).
379     </para>
380     <para>
381      If no attribute specifications matches the attribute list in a query,
382      it is accepted.
383     </para>
384     <para>
385      The <literal>attribute</literal> element has two required attributes:
386      <literal>type</literal> which is the Attribute Type-1 type, and
387      <literal>value</literal> which is the Attribute Type-1 value.
388      The special value/type <literal>*</literal> matches any attribute
389      type/value. A value may also be specified as a list with each
390      value separated by comma, a value may also be specified as a
391      list: low value - dash - high value.
392     </para>
393     <para>
394      If attribute <literal>error</literal> is given, that holds a 
395      Bib-1 diagnostic which is sent to the client if the particular
396      type, value is part of a query.
397     </para>
398     <para>
399      If attribute <literal>error</literal> is not given, the attribute
400      type, value is accepted and passed to the backend target.
401     </para>
402     <para>
403      A target that supports use attributes 1,4, 1000 through 1003 and
404      no other use attributes, could use the following rules:
405      <screen>
406       &lt;attribute type="1" value="1,4,1000-1003"/>
407       &lt;attribute type="1" value="*" error="114"/>
408      </screen>
409     </para>
410    </section>
411    <section id="proxy-config-syntax">
412     <title>syntax</title>
413     <para>
414      The <literal>syntax</literal> element specifies accept or reject
415      or a particular record syntax request from the client.
416     </para>
417     <para>
418      The <literal>syntax</literal> has one required attribute:
419      <literal>type</literal> which is the Preferred Record Syntax.
420     </para>
421     <para>
422      If attribute <literal>error</literal> is given, that holds a 
423      Bib-1 diagnostic which is sent to the client if the particular
424      record syntax is part of a present - or search request.
425     </para>
426     <para>
427      If attribute <literal>error</literal> is not given, the record syntax
428      is accepted and passed to the backend target.
429     </para>
430     <para>
431      If attribute <literal>marcxml</literal> is given, the proxy will
432      perform MARC21 to MARCXML conversion. In this case the
433      <literal>type</literal> should be XML. The proxy will use
434      preferred record syntax USMARC/MARC21 or <literal>backendtype</literal> 
435      (if given) against the backend target.
436      For the special case where <literal>backendtype</literal> is
437      <literal>opac</literal> the proxy will convert the OPAC
438      record to OPACXML.
439     </para>
440     <para>
441      If attribute <literal>backendtype</literal> is given, that holds the
442      record syntax to be transmitted to backend.
443     </para>
444     <para>
445      If attribute <literal>stylesheet</literal> is given, the proxy
446      will convert XML record from server via XSLT. It is important
447      that the content from server is XML. If used in conjunction with
448      attribute <literal>marcxml</literal>, the MARC to MARCXML/OPACXML
449      conversion takes place before the XSLT conversion takes place.
450     </para>
451     <para>
452      If attribute <literal>identifier</literal> is given that is the
453      SRU record schema identifier for the resulting output record (after
454      MARCXML and/or XSLT conversion). 
455     </para>
456     <para>
457      If sub element <literal>title</literal> is given (as child element
458      of <literal>syntax</literal>, then that is the official SRU
459      name of the resulting record schema.
460     </para>
461     <para>
462      If sub element <literal>name</literal> is given that is an alias
463      for the record schema identifier. Multiple <literal>name</literal>s
464      may be specified.
465     </para>
466     <example>
467      <title>MARCXML conversion</title>
468      <para>To accept USMARC and offer MARCXML XML plus Dublin Core (via
469       XSLT conversion) but the following configuration could be used:
470       <screen>
471        &lt;proxy>
472        &lt;target name="mytarget">
473        ..
474        &lt;syntax type="usmarc"/>
475        &lt;syntax type="xml" marcxml="1"
476          identifier="info:srw/schema/1/marcxml-v1.1"
477          &lt;title>MARCXML&lt;title>
478          &lt;name>marcxml&lt;name>
479        &lt;/syntax>
480        &lt;syntax type="xml" marcxml="1" stylesheet="MARC21slim2SRWDC.xsl"
481          identifier="info:srw/schema/1/dc-v1.1">
482          &lt;title>Dublin Core&lt;title>
483          &lt;name>dc&lt;name>
484        &lt;/syntax>
485        &lt;syntax type="*" error="238"/>
486        ..
487        &lt;/target>
488        &lt;/proxy>
489       </screen>
490     </para>
491     </example>
492
493    </section>
494
495    <section id="proxy-config-explain">
496     <title>explain</title>
497     <para>
498      The <literal>explain</literal> element includes Explain information
499      for SRU about the server in the target section. This
500      information must have a <literal>serverInfo</literal> element
501      with a database that this target must be available as (URL path).
502      For example,
503      <screen><![CDATA[
504       <explain xmlns="http://explain.z3950.org/dtd/2.0/">     
505         <serverInfo>
506           <host>myhost.org</host>
507           <port>8000</port>
508           <database>mydatabase</database>
509         </serverInfo>
510         <!-- remaining Explain stuff -->
511       </explain>
512       ]]>
513      </screen>
514      In the above case, the SRU service is available as
515      <literal>http://myhost.org:8000/mydatabase</literal>.
516     </para>
517     
518    </section>
519
520    <section id="proxy-config-cql2rpn">
521     <title>cql2rpn</title>
522     <para>
523      The content of the <literal>cql2rpn</literal> element specifies
524      the path from the working directory to a CQL-to-RPN conversion
525      file for the server in the target section. This element
526      is required for SRU searches to operate against Z39.50
527      servers that don't support CQL. Most Z39.50 servers only support
528      Type-1/RPN so this is usually required.
529     </para>
530     <para>
531      See YAZ documentation for more information about the
532      <ulink url="&url.yaz.cql2pqf;">CQL to PQF</ulink> conversion.
533      See also the
534      <filename>pqf.properties</filename> in the <filename>etc</filename> 
535      (or <replaceable>prefix/share/yazproxy</replaceable>)
536      directory of the YAZ proxy distribution.
537     </para>
538    </section>
539    
540    <section id="proxy-config-preinit">
541     <title>preinit</title>
542     <para>
543      The element <literal>preinit</literal> is the child of element
544      <literal>target</literal> and specifies the number of spare
545      connection to a target. By default no spare connection are
546      created by the proxy. If the proxy uses a target exclusive or
547      a lot, the preinit session will ensure that target sessions
548      have been made before the client makes a connection and will therefore
549      reduce the connect-init handshake dramatically. Never set this to
550      more than 5.
551     </para>
552    </section>
553
554    <section id="proxy-config-target-authentication">
555     <title>target-authentication</title>
556     <para>
557      The element <literal>target-authentication</literal> specifies
558      fixed authentication information to be sent to the backend target.
559     </para>
560     <para>
561      This element takes a an attribute <literal>type</literal> which is
562      the authenticatin type to be used.. 
563     </para>
564     <variablelist>
565      <varlistentry><term><literal>none</literal></term>
566       <listitem>
567        <para>
568         No authentication. There is no CDATA associated with this.
569        </para>
570       </listitem>
571      </varlistentry>
572
573      <varlistentry><term><literal>anonymous</literal></term>
574       <listitem>
575        <para>
576         Anonymous authentication. There is no CDATA associated with this.
577        </para>
578       </listitem>
579      </varlistentry>
580
581      <varlistentry><term><literal>open</literal></term>
582       <listitem>
583        <para>
584         Open authentication. The CDATA consists of the
585         open authentication string.
586        </para>
587       </listitem>
588      </varlistentry>
589
590      <varlistentry><term><literal>idPass</literal></term>
591       <listitem>
592        <para>
593         IdPass authentication. The CDATA consists of
594         three terms: user, group and password.
595        </para>
596       </listitem>
597      </varlistentry>
598     </variablelist>
599    </section>
600
601    <section id="proxy-config-target-charset">
602     <title>target-charset</title>
603     <para>
604      The element <literal>target-charset</literal> specifies the
605      native character set that the target uses for queries.
606     </para>
607     <para>
608      If this is specified the proxy will act as a Z39.50 server
609      supporting character set negotiation. And in SRU mode
610      it will convert from UTF-8 (UNICODE) to this native character
611      set (if possible).
612     </para>
613    </section>
614
615    <section id="proxy-config-max-clients">
616     <title>max-clients</title>
617     <para>
618      The element <literal>max-clients</literal> is the child of element
619      <literal>proxy</literal> and specifies the total number of
620      allowed connections to targets (all targets). If this limit
621      is reached the proxy will close the least recently used connection.
622     </para>
623     <para>
624      Note, that many Unix systems impose a system on the number of
625      open files allowed in a single process, typically in the 
626      range 256 (Solaris) to 1024 (Linux).
627      The proxy uses 2 sockets per session + a few files
628      for logging. As a rule of thumb, ensure that 2*max-clients + 5
629      can be opened by the proxy process.
630     </para>
631     <tip>
632      <para>
633       Using the <ulink url="&url.bash;">bash</ulink> shell, you can set
634       the limit with
635       <literal>ulimit -n</literal><replaceable>no</replaceable>. 
636        Use <literal>ulimit -a</literal> to display limits.
637      </para>
638      </tip>
639    </section>
640
641    <section id="proxy-config-log">
642     <title>log</title>
643     <para>
644      The element <literal>log</literal> is the child of element
645      <literal>proxy</literal> and specifies what to be logged by the
646      proxy.
647      </para>
648     <para>
649      Specify the log file with command-line option <literal>-l</literal>.
650     </para>
651     <para>
652      The text of the <literal>log</literal> element is a sequence of
653      options separated by white space. See the table below:
654      <table frame="top"><title>Logging options</title>
655       <tgroup cols="2">
656        <colspec colwidth="1*"/>
657        <colspec colwidth="2*"/><thead>
658         <row>
659          <entry>Option</entry>
660          <entry>Description</entry>
661         </row>
662        </thead>
663        <tbody>
664         <row>
665          <entry><literal>client-apdu</literal></entry>
666          <entry>
667           Log APDUs as reported by YAZ for the
668           communication between the client and the proxy.
669           This facility is equivalent to the APDU logging that
670           happens when using option <literal>-a</literal>, however
671           this tells the proxy to log in the same file as given
672           by <literal>-l</literal>.
673          </entry>
674         </row>
675         <row>
676          <entry><literal>server-apdu</literal></entry>
677          <entry>
678           Log APDUs as reported by YAZ for the
679           communication between the proxy and the server (backend).
680          </entry>
681         </row>
682         <row>
683          <entry><literal>clients-requests</literal></entry>
684          <entry>
685           Log a brief description about requests transferred between
686           the client and the proxy. The name of the request and the size
687           of the APDU is logged.
688          </entry>
689         </row>
690         <row>
691          <entry><literal>server-requests</literal></entry>
692          <entry>
693           Log a brief description about requests transferred between
694           the proxy and the server (backend). The name of the request
695           and the size of the APDU is logged.
696          </entry>
697         </row>
698         <row>
699          <entry><literal>client-ip</literal></entry>
700          <entry>
701           Log the client IP for each log entry. By default, the client IP
702           is only logged when a new session starts.
703          </entry>
704         </row>
705        </tbody>
706       </tgroup>
707      </table>
708     </para>
709     <para>
710      To log communication in details between the proxy and the backend, th
711      following configuration could be used:
712      <screen><![CDATA[
713       <target name="mytarget">
714        <log>server-apdu server-requests</log>
715       </target>
716       ]]>
717      </screen>
718     </para>
719    </section>
720
721    <section id="proxy-max-connect">
722     <title>max-connect</title>
723     <para>
724      The element <literal>max-connect</literal> is a child of element
725      <literal>proxy</literal> and specifies the maximum number
726      of connections to be initiated within the last minute (or
727      value of <link linkend="proxy-period-connect">period-connect</link>.
728     </para>
729     <para>
730      If the maximum number is reached the proxy will terminate the
731      just initiated session (connection terminated).
732     </para>
733    </section>
734
735    <section id="proxy-limit-connect">
736     <title>limit-connect</title>
737     <para>
738      The element <literal>max-connect</literal> is a child of element
739      <literal>proxy</literal> and specifies the limit of number
740      of connections to be initiated within the last minute (or
741      value of <link linkend="proxy-period-connect">period-connect</link>.
742     </para>
743     <para>
744      If the maximum number is reached the proxy delays the first operation
745      in the session by one second.
746     </para>
747    </section>
748
749    <section id="proxy-period-connect">
750     <title>period-connect</title>
751     <para>
752      The element <literal>period-connect</literal> is a child of element
753      <literal>proxy</literal> and specifies period - in the number of seconds
754      that <link linkend="proxy-limit-connect">limit-connect</link> and 
755      <link linkend="proxy-max-connect">max-connect</link>
756      should measure connections.
757     </para>
758     <para>
759      If <literal>period-connect</literal> is omitted, 60 seconds is used.
760     </para>
761    </section>
762
763    <section id="proxy-docpath">
764     <title>docpath</title>
765     <para>
766      The element <literal>docpath</literal> is a child of element
767      <literal>proxy</literal> and specifies an allowed HTTP path
768      for local file access. Using <literal>docpath</literal> the
769      proxy may return static file content.
770     </para>
771     <para>
772      The value of docpath both serves as a HTTP path prefix 
773      <emphasis>and</emphasis> as a local file prefix. 
774      If a value of <literal>etc</literal> is used only URLs with the
775      prefix <literal>/etc/</literal> results in a local file access to the
776      directory <literal>etc</literal> within the working directory
777      of yazproxy.
778     </para>
779     <note>
780     <para>
781       Care has been taken to ensure that hostile URLs are rejected - including
782       strings such as <literal>..</literal> and <literal>/</literal> (absolute
783       file system access).
784      </para>
785     </note>
786    </section>
787
788   </section>
789   <section id="proxy-usage">
790    <title>Proxy Manual Pages</title>
791    <refentry id="yazproxy-man">
792     &yaz-proxy-ref;
793    </refentry>
794   </section>
795   
796   <section id="otherinfo-encoding">
797    <title>OtherInformation Encoding</title>
798    <para>
799     The proxy uses the OtherInformation definition to carry
800     information about the target address and cookie.
801    </para>
802    <screen>
803   OtherInformation   ::= [201] IMPLICIT SEQUENCE OF SEQUENCE{
804     category           [1]   IMPLICIT InfoCategory OPTIONAL, 
805     information        CHOICE{
806       characterInfo            [2]  IMPLICIT InternationalString,
807       binaryInfo               [3]  IMPLICIT OCTET STRING,
808       externallyDefinedInfo    [4]  IMPLICIT EXTERNAL,
809       oid                      [5]  IMPLICIT OBJECT IDENTIFIER}}
810 --
811   InfoCategory ::= SEQUENCE{
812       categoryTypeId   [1]   IMPLICIT OBJECT IDENTIFIER OPTIONAL,
813       categoryValue    [2]   IMPLICIT INTEGER}
814   </screen>
815    <para>
816     The <literal>categoryTypeId</literal> is either
817     OID 1.2.840.10003.10.1000.81.1, 1.2.840.10003.10.1000.81.2
818     for proxy target and proxy cookie respectively. The
819     <literal>categoryValue</literal> is set to 1.
820     The value proxy and cookie is stored in element
821     <literal>characterInfo</literal> of the <literal>information</literal>
822      choice.
823    </para>
824   </section>
825   <section id="yazproxy-schema">
826    <title>YAZ Proxy Configuration Schema</title>
827    <para>
828     Here an XML Schema for the YAZ proxy configuration file. 
829     The schema, <filename>yazproxy.xsd</filename> is located in sub
830     directory <filename>etc</filename> of the distribution.
831    </para>
832    <screen><![CDATA[
833 <?xml version="1.0"?>
834 <!-- XML Schema for YAZ proxy config file.
835     $Id: reference.xml,v 1.20 2006-06-14 10:12:26 adam Exp $
836 -->
837 <xs:schema
838   xmlns:xs="http://www.w3.org/2001/XMLSchema"
839   xmlns:exp="http://explain.z3950.org/dtd/2.0/"
840   xmlns="http://indexdata.dk/yazproxy/schema/0.9/"
841   targetNamespace="http://indexdata.dk/yazproxy/schema/0.9/"
842   >
843  <xs:import namespace="http://explain.z3950.org/dtd/2.0/" 
844       schemaLocation="zeerex-2.0.xsd"/>
845  <xs:element name="proxy">
846   <xs:complexType>
847    <xs:sequence>
848     <xs:element ref="target" minOccurs="0" maxOccurs="unbounded"/>
849     <xs:element ref="max-clients" minOccurs="0"/>
850     <xs:element ref="log" minOccurs="0"/>
851     <xs:element ref="module" minOccurs="0"/>
852    </xs:sequence>
853   </xs:complexType>
854  </xs:element>
855
856  <xs:element name="target">
857   <xs:complexType>
858    <xs:sequence>
859      <xs:element ref="url" minOccurs="0" maxOccurs="unbounded"/>
860      <xs:element ref="target-timeout" minOccurs="0"/>
861      <xs:element ref="client-timeout" minOccurs="0"/>
862      <xs:element ref="keepalive" minOccurs="0"/>
863      <xs:element ref="limit" minOccurs="0"/>
864      <xs:element ref="attribute" minOccurs="0" maxOccurs="unbounded"/>
865      <xs:element ref="syntax" minOccurs="0" maxOccurs="unbounded"/>
866      <xs:element ref="preinit" minOccurs="0"/>
867      <xs:element ref="exp:explain" minOccurs="0"/>
868      <xs:element ref="cql2rpn" minOccurs="0"/>
869      <xs:element ref="target-authentication" minOccurs="0"/>
870      <xs:element ref="client-authentication" minOccurs="0"/>
871      <xs:element ref="negotiation-charset" minOccurs="0"/>
872      <xs:element ref="negotiation-lang" minOccurs="0"/>
873    </xs:sequence>
874    <xs:attribute name="default" type="xs:string" use="optional"/>
875    <xs:attribute name="name" type="xs:string"/>
876    <xs:attribute name="database" type="xs:string"/>
877   </xs:complexType>
878  </xs:element>
879
880  <xs:element name="url" type="xs:string"/>
881  <xs:element name="target-timeout" type="xs:integer"/>
882  <xs:element name="client-timeout" type="xs:integer"/>
883  <xs:element name="bandwidth" type="xs:integer"/>
884  <xs:element name="pdu" type="xs:integer"/>
885  <xs:element name="retrieve" type="xs:integer"/>
886  <xs:element name="preinit" type="xs:integer"/>
887  <xs:element name="cql2rpn" type="xs:string"/>
888  <xs:element name="target-authentication">
889    <xs:complexType>
890     <xs:simpleContent>
891       <xs:extension base="xs:string">
892         <xs:attribute name="type" type="xs:string"/>
893       </xs:extension>
894     </xs:simpleContent>
895    </xs:complexType>
896  </xs:element>
897
898  <xs:element name="client-authentication">
899    <xs:complexType>
900     <xs:simpleContent>
901       <xs:extension base="xs:string">
902         <xs:attribute name="module" type="xs:string"/>
903         <xs:attribute name="args" type="xs:string"/>
904       </xs:extension>
905     </xs:simpleContent>
906    </xs:complexType>
907  </xs:element>
908
909  <xs:element name="negotiation-charset" type="xs:string"/>
910  <xs:element name="negotiation-lang" type="xs:string"/>
911
912  <xs:element name="keepalive">
913   <xs:complexType>
914    <xs:sequence>
915     <xs:element ref="bandwidth" minOccurs="0"/>
916     <xs:element ref="pdu" minOccurs="0"/>
917    </xs:sequence>
918   </xs:complexType>
919  </xs:element>
920  <xs:element name="limit">
921   <xs:complexType>
922    <xs:sequence>
923     <xs:element ref="bandwidth" minOccurs="0"/>
924     <xs:element ref="pdu" minOccurs="0"/>
925     <xs:element ref="retrieve" minOccurs="0"/>
926    </xs:sequence>
927   </xs:complexType>
928  </xs:element>
929  
930  <xs:element name="attribute">
931   <xs:complexType>
932    <xs:attribute name="type" type="xs:string"/>
933    <xs:attribute name="value" type="xs:string"/>
934    <xs:attribute name="error" type="xs:integer"/>
935   </xs:complexType>
936  </xs:element>
937
938  <xs:element name="syntax">
939   <xs:complexType>
940    <xs:sequence>
941     <xs:element ref="title" minOccurs="0"/>
942     <xs:element ref="name" minOccurs="0" maxOccurs="unbounded"/>
943    </xs:sequence>
944    <xs:attribute name="error" type="xs:string" />
945    <xs:attribute name="type" type="xs:string" />
946    <xs:attribute name="marcxml" type="xs:string" />
947    <xs:attribute name="identifier" type="xs:string" />
948    <xs:attribute name="stylesheet" type="xs:string" />
949    <xs:attribute name="backendtype" type="xs:string" />
950    <xs:attribute name="backendcharset" type="xs:string" />
951    <xs:attribute name="usemarconstage1" type="xs:string" />
952    <xs:attribute name="usemarconstage2" type="xs:string" />
953   </xs:complexType>
954  </xs:element>
955
956  <xs:element name="title" type="xs:string"/>
957  <xs:element name="name" type="xs:string"/>
958
959  <xs:element name="max-clients" type="xs:integer"/>
960  <xs:element name="log" type="xs:string"/>
961  <xs:element name="module" type="xs:string"/>
962
963 </xs:schema>
964 ]]>
965    </screen>
966   </section>
967  </chapter>
968
969  <!-- Keep this comment at the end of the file
970  Local variables:
971  mode: sgml
972  sgml-omittag:t
973  sgml-shorttag:t
974  sgml-minimize-attributes:nil
975  sgml-always-quote-attributes:t
976  sgml-indent-step:1
977  sgml-indent-data:t
978  sgml-parent-document: "yazproxy.xml"
979  sgml-local-catalogs: nil
980  sgml-namecase-general:t
981  End:
982  -->
983