added a lot of info about attribute sets, PQF query structure, and string use attributes
[idzebra-moved-to-github.git] / doc / zebrasrv-virtual.xml
1 <!-- 
2    $Id: zebrasrv-virtual.xml,v 1.7 2006-06-13 13:45:08 marc Exp $
3    Description of the virtual host mechanism in YAZ GFS
4    Included in both manual and man page for yaz-ztest
5 -->
6
7 <para>
8  The Virtual hosts mechanism allows a YAZ frontend server to
9  support multiple backends. A backend is selected on the basis of
10  the TCP/IP binding (port+listening adddress) and/or the virtual host.
11 </para>
12 <para>
13  A backend can be configured to execute in a particular working
14  directory. Or the YAZ frontend may perform <ulink url="&url.cql;">CQL</ulink> to RPN conversion, thus
15  allowing traditional Z39.50 backends to be offered as a  <ulink url="http://www.loc.gov/standards/sru/srw/">SRW</ulink>/ <ulink url="&url.sru;">SRU</ulink>
16  service.  <ulink url="http://www.loc.gov/standards/sru/srw/">SRW</ulink>/ <ulink url="&url.sru;">SRU</ulink> Explain information for a particular backend may also
17  be specified.
18 </para>
19 <para>
20  For the HTTP protocol, the virtual host is specified in the Host header.
21  For the Z39.50 protocol, the virtual host is specified as in the
22  Initialize Request in the OtherInfo, OID 1.2.840.10003.10.1000.81.1.
23 </para>
24 <note>
25  <para>
26   Not all Z39.50 clients allows the VHOST information to be set.
27   For those the selection of the backend must rely on the
28   TCP/IP information alone (port and address).
29  </para>
30 </note>
31 <para>
32  The YAZ frontend server uses XML to describe the backend
33  configurations. Command-line option <literal>-f</literal> 
34  specifies filename of the XML configuration.
35 </para>
36 <para>
37  The configuration uses the root element <literal>yazgfs</literal>.
38  This element includes a list of <literal>listen</literal> elements,
39  followed by one or more <literal>server</literal> elements.
40 </para>
41 <para>
42  The <literal>listen</literal> describes listener (transport end point),
43  such as TCP/IP, Unix file socket or SSL server. Content for 
44  a listener:
45  <variablelist>
46   <varlistentry><term>CDATA (required)</term>
47    <listitem>
48     <para>
49      The CDATA for the <literal>listen</literal> element holds the
50      listener string, such as <literal>tcp:@:210</literal>, 
51      <literal>tcp:server1:2100</literal>,
52      etc.
53     </para>
54    </listitem>
55   </varlistentry>
56   <varlistentry><term>attribute <literal>id</literal> (optional)</term>
57     <listitem>
58      <para>
59       identifier for this listener. This may be referred to from
60       server sections.
61      </para>
62     </listitem>
63    </varlistentry>
64  </variablelist>
65  <note>
66   <para>
67    We expect more information to be added for the listen section in
68    a future version, such as CERT file for SSL servers.
69   </para>
70  </note>
71 </para>
72 <para>
73  The <literal>server</literal> describes a server and the parameters
74  for this server type. Content for a server:
75  <variablelist>
76   <varlistentry><term>attribute <literal>id</literal> (optional)</term>
77    <listitem>
78     <para>
79      Identifier for this server. Currently not used for anything,
80      but it might be for logging purposes.
81    </para>
82    </listitem>
83   </varlistentry>
84
85   <varlistentry><term>attribute <literal>listenref</literal> (optional)</term>
86    <listitem>
87     <para>
88      Specifies listener for this server. If this attribute is not
89      given, the server is accessible from all listener. In order
90      for the server to be used for real, howeever, the virtual host
91      must match (if specified in the configuration).
92     </para>
93    </listitem>
94   </varlistentry>
95
96   <varlistentry><term>element <literal>config</literal> (optional)</term>
97    <listitem>
98     <para>
99      Specifies the server configuration. This is equivalent
100      to the config specified using command line option
101      <literal>-c</literal>.
102     </para>
103    </listitem>
104   </varlistentry>
105
106   <varlistentry><term>element <literal>directory</literal> (optional)</term>
107    <listitem>
108     <para>
109      Specifies a working directory for this backend server. If
110      specifid, the YAZ fronend changes current working directory
111      to this directory whenever a backend of this type is
112      started (backend handler bend_start), stopped (backend handler hand_stop)
113      and initialized (bend_init).
114     </para>
115    </listitem>
116   </varlistentry>
117
118   <varlistentry><term>element <literal>host</literal> (optional)</term>
119    <listitem>
120     <para>
121      Specifies the virtual host for this server. If this is specified
122      a client <emphasis>must</emphasis> specify this host string in
123      order to use this backend.
124     </para>
125    </listitem>
126   </varlistentry>
127
128   <varlistentry><term>element <literal>cql2rpn</literal> (optional)</term>
129    <listitem>
130     <para>
131      Specifies a filename that includes <ulink url="&url.cql;">CQL</ulink> to RPN conversion for this
132      backend server. See <ulink url="&url.cql;">CQL</ulink> section in YAZ manual.
133      If given, the backend server will only "see" a Type-1/RPN query. 
134     </para>
135    </listitem>
136   </varlistentry>
137    
138   <varlistentry><term>element <literal>explain</literal> (optional)</term>
139    <listitem>
140     <para>
141      Specifies  <ulink url="http://www.loc.gov/standards/sru/srw/">SRW</ulink>/ <ulink url="&url.sru;">SRU</ulink> ZeeRex content for this server. Copied verbatim
142      to the client. As things are now, some of the Explain content
143      seems redundant because host information, etc. is also stored
144      elsewhere.
145     </para>
146     <para>
147      The format of the Explain record is described in detail, with
148      examples, on the file ZeeRex web-site,
149      <ulink url="http://explain.z3950.org/"></ulink>.
150     </para>
151    </listitem>
152   </varlistentry>
153  </variablelist>
154 </para>
155  
156 <para>
157  The XML below configures a server that accepts connections from
158  two ports, TCP/IP port 9900 and a local UNIX file socket.
159  We name the TCP/IP server <literal>public</literal> and the
160  other server <literal>internal</literal>.
161  </para>
162  <screen>
163   <![CDATA[
164  <yazgfs>
165   <listen id="public">tcp:@:9900</listen>
166   <listen id="internal">unix:/var/tmp/socket</listen>
167   <server id="server1">
168     <host>server1.mydomain</host>
169     <directory>/var/www/s1</directory>
170     <config>config.cfg</config>
171   </server>
172   <server id="server2">
173     <host>server2.mydomain</host>
174     <directory>/var/www/s2</directory>
175     <config>config.cfg</config>
176     <cql2rpn>../etc/pqf.properties</cql2rpn>
177     <explain xmlns="http://explain.z3950.org/dtd/2.0/">
178       <serverInfo>
179         <host>server2.mydomain</host>
180         <port>9900</port>
181         <database>a</database>
182       </serverInfo>
183     </explain>
184   </server>
185   <server id="server3" listenref="internal">
186     <directory>/var/www/s3</directory>
187     <config>config.cfg</config>
188   </server>
189  </yazgfs>
190 ]]>
191  </screen>
192 <para>
193  There are three configured backend servers. The first two
194  servers, <literal>"server1"</literal> and <literal>"server2"</literal>,
195  can be reached by both listener addresses - since
196  no <literal>listenref</literal> attribute is specified.
197  In order to distinguish between the two a virtual host has
198  been specified for each of server in the <literal>host</literal>
199  elements.
200 </para>
201 <para>
202  For <literal>"server2"</literal> elements for 
203 <ulink url="&url.cql;">CQL</ulink> to RPN conversion
204  is supported and explain information has been added (a short one here
205  to keep the example small).
206 </para>
207 <para>
208  The third server, <literal>"server3"</literal> can only be reached
209  via listener <literal>"internal"</literal>.
210 </para>
211
212 <!-- Keep this comment at the end of the file
213 Local variables:
214 mode: sgml
215 sgml-omittag:t
216 sgml-shorttag:t
217 sgml-minimize-attributes:nil
218 sgml-always-quote-attributes:t
219 sgml-indent-step:1
220 sgml-indent-data:t
221 sgml-parent-document: "yaz.xml"
222 sgml-local-catalogs: nil
223 sgml-namecase-general:t
224 End:
225 -->