- 5.1 The magnus.conf File
- 5.2 The server.xml File
- 5.3 The obj.conf File
- 5.4 The mime.types File
- 5.5 Trust Database Files (*.db Files)
- 5.6 The server.policy File
- 5.7 The certmap.conf File
- 5.8 The default.acl File
- 5.9 The default-web.xml File
- 5.10 The login.conf File
- 5.11 The keyfile File
- 5.12 Summary
- 5.13 Self-Paced Labs
5.3 The obj.conf File
The obj.conf (or object configuration) file contains instructions on how to process HTTP client requests. This file consists of various directives that map directly to request processing stages and enable your Web Server to process client requests immediately after installation.
An initial object configuration file is created for each Web Server configuration; the name of the file is simply obj.conf. Additional object configuration files may also exist for any virtual servers created using the Administration Console or command line interface. The default name for each virtual server object configuration file is vsname-obj.conf (where vsname is the name of the virtual server). The <object-file> element in the server.xml file specifies the name of the object configuration file to use to process requests for that virtual server. Example 5.3 demonstrates the use of the <object-file> element in the server.xml file.
Example 5.3. Virtual Server Definition for the Object Configuration File
<virtual-server> <name>www.example.com</name> <http-listener-name>http-listener-1</http-listener-name> <host>www.example.com</host> <object-file>www.example.com-obj.conf</object-file> <document-root>/export/home/example.com/public_html</document-root> <access-log> <file>/export/home/example.com/logs/access</file> </access-log> </virtual-server>
When the Web Server receives a request, it uses information contained within the server.xml file to select an appropriate virtual server. It then uses the file specified by the <object-file> element to determine how to process the request. Multiple object configuration files allow the flexibility to process requests differently for each virtual server.
5.3.1 File Structure
The obj.conf file contains a series of instructions (or directives) that tell the server what to do at each stage of the request-handling process. These directives are grouped together by <Object> tags. Each directive invokes a SAF with one or more arguments.
Example 5.4 demonstrates the obj.conf file for the default Administration Node.
Example 5.4. Default obj.conf File
# # Copyright 2006 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # You can edit this file, but comments and formatting changes # might be lost when you use the administration GUI or CLI. <Object name="default"> AuthTrans fn="match-browser" browser="*MSIE*" ssl-unclean-shutdown="true" NameTrans fn="ntrans-j2ee" name="j2ee" NameTrans fn="pfx2dir" from="/mc-icons" dir="/opt/webserver7/lib/icons" name="es-internal" PathCheck fn="unix-uri-clean" PathCheck fn="find-pathinfo" PathCheck fn="find-index-j2ee" PathCheck fn="find-index" index-names="index.html,home.html,index.jsp" ObjectType fn="type-j2ee" ObjectType fn="type-by-extension" ObjectType fn="force-type" type="text/plain" Service method="(GET|HEAD)" type="magnus-internal/directory" fn="index-common" Service method="(GET|HEAD|POST)" type="*~magnus-internal/*" fn="send-file" Service method="TRACE" fn="service-trace" Error fn="error-j2ee" AddLog fn="flex-log" </Object> <Object name="j2ee"> Service fn="service-j2ee" method="*" </Object> <Object name="es-internal"> </Object> <Object name="es-internal"> </Object> <Object name="cgi"> ObjectType fn="force-type" type="magnus-internal/cgi" Service fn="send-cgi" </Object> <Object name="send-precompressed"> PathCheck fn="find-compressed" </Object> <Object name="compress-on-demand"> Output fn="insert-filter" filter="http-compression" </Object>
Directives in the object configuration file follow a syntax similar to those contained in the magnus.conf (refer to Table 5.2 for details). The exception is that the object configuration file also contains objects (called templates) for grouping directives together. Templates enable you to process directives on a conditional basis.
The overall structure of the object configuration file is as follows:
<Object name="default"> directives </Object> <Object name="objectname"> directives </Object> ... <Object name="objectname"> directives </Object>
The order of these templates is not important, but there must exist one template with the name default. The directives contained in the default template are used to process every request. The object configuration file for Web Server 7 contains a standard default template with directives for standard request processing. This enables you to process requests immediately after installation.
Some syntax errors in the object configuration file might cause situations where the server instance cannot start, whereas others might not be noticed until a request is processed.
Examples of errors that prevent an instance from starting include an incorrect spelling of the directive name or the name of a directive parameter and can be found in the following example:
NameTrans func="pfx2dir" from="/mc-icons" dir="/opt/webserver7/lib/ icons" name="es-internal"
In this example, the directive parameter, fn, has been incorrectly specified as func. If this were to occur, you would see an error similar to the following when you attempted to start the instance:
config: CONF2265: Error parsing file obj.conf, line 12, column 1: Missing parameter (need fn) config: CORE3235: File server.xml line 71: Error processing <object-file> element: Error processing file obj.conf failure: server initialization failed
Other syntax errors are not so easily noticed and might not be recognized until a request is processed. For example, if you specify an incorrect SAF in the function (fn) specification as follows:
NameTrans fn="badfunc" from="/mc-icons" dir="/opt/webserver7/lib/ icons" name="es-internal"
you would see a warning message at start-up as follows:
config: trying to GET /, func_exec reports: HTTP2122: cannot find function named badfunc
and the following message in the errors log:
[22/Jul/2007:08:23:55] config ( 3546): for host 184.108.40.206 trying to GET /mc-icons/image.gif, func_exec reports: HTTP2122: cannot find function named badfunc info: HTTP3072: http-listener-1: http://www.example.com:80 ready to accept requests info: CORE3274: successful server startup
These types of errors might not be noticed if the instance is configured to start when the server reboots. Instead, the server might start properly and flag an error message, but it isn’t until a request comes in for that resource that the server error is noticed.
The following subsections contain an overview of directives and objects found in the object configuration file. Refer to Chapter 6 for a detailed explanation of request processing.
Directives in the object configuration file invoke SAFs at various request processing stages. The stage is specified as the first parameter of the directive.
Each directive calls a function and specifies zero or more parameters that are necessary for the SAF to process the request at that stage. The function name and/or parameters are specified with reserved words, so the order in which they appear in the directive is not important. In general, however, the syntax for each directive in the object configuration file is as follows:
Directive fn="function" name1="value1" ... nameN="valueN"
Where Directive is the stage at which the directive is processed. The value of the function (fn) parameter is the name of the SAF to execute. All directives must supply a value for the fn parameter; if there is no function, the instruction will do nothing. Function names can be composed of letters, digits, underscores (_), or hyphens (-). The remaining parameters are the arguments needed by the function, and they vary from function to function.
An example of a directive that applies to the NameTrans (Name Translation) stage of request processing would be
NameTrans fn="document-root" root="/opt/Sun/webserver7/https-www. example.com/docs"
In this example, the directive is executed during the NameTrans stage of request processing and invokes the document-root SAF to specify the document root directory for the server. The document-root SAF uses one parameter, root, to specify the path to the document root directory.
Parameters can contain references to variables and expressions. The variables can be predefined variables, variables defined at request time using the set-variable SAF, or variables defined in server.xml.
It is not required, but it is a best practice to group directives according to the stage in which they are processed (for example, all NameTrans directives should be grouped together). This enables you to easily recognize and debug problems within the object configuration file.
The order in which directives appear within a particular group becomes important if the directives are conditionally executed. A common error is to place directives that are processed unconditionally before those that are conditional in nature. In such a case, the conditional directives might never be processed.
Another best practice is to place directive groups in the order of request processing stages (for example, AuthTrans, NameTrans, PathCheck, ObjectType, Service, Error, and AddLog) because this also aids in debugging.
Directives in the object configuration file are grouped together by objects (which are also referred to as containers or templates). Objects are specified by the <Object> tag and enable you to define directives that are executed only on certain conditions. Example 5.4 demonstrates various objects that are defined as part of the default object configuration file.
One of the most common attributes for the <Object> tag is the name attribute, which uniquely identifies the object within the configuration file. The syntax for objects that use the name attribute is as follows:
<Object name="objectname"> directives </Object>
The object configuration file contains a default object that tells the instance how to process requests by default.
<Object name="default"> directives </Object>
The object configuration file can contain objects that are executed only when certain conditions are true for a particular NameTrans directive. Two such conditions involve the use of additional named objects or ppath objects.
Named Object Processing
One such example of conditional processing is the use of the optional name attribute in the NameTrans directive. Assume that a client is requesting the following URL:
During request processing, the server evaluates each NameTrans directive in the default object in an attempt to locate a match. In this case, the second directive is matched because the URI begins with /mc-icons.
NameTrans fn="ntrans-j2ee" name="j2ee" NameTrans fn="pfx2dir" from="/mc-icons" dir="/opt/webserver7/lib/ icons" name="es-internal"
The server then determines whether a name attribute has been specified for the directive.
NameTrans fn="pfx2dir" from="/mc-icons" dir="/opt/webserver7/lib/ icons" name="es-internal"
If the directive specifies a name attribute, the value of the attribute points to another object that contains additional directives that should be used for processing the request.
<Object name="es-internal"> directives </Object>
Any directives found in the additional object are processed prior to those found in the default object for the particular stage being processed.
ppath Object Processing
Another example of conditional processing is the use of the ppath (partial path) object.
<Object ppath="path"> directives </Object>
The ppath object enables you to specify a path to a document or resource where directives contained in the object are executed only if the path to the resource can be found beneath the location specified in the ppath value. For example, suppose you specify a ppath object as follows:
<Object ppath="/opt/webserver7/https-www.example.com/docs/ private/*"> directives </Object>
During the processing of the NameTrans directive, if it is determined that the resource can be found beneath the /opt/webserver7/https-www.example.com/docs/private/ directory, then any directives found within this ppath object are processed prior to those found in the default object.
In general, the server always starts processing requests with the default object and may process directives in other objects based on conditions within the NameTrans directive. Each new object added to the object configuration file has the potential to modify the default object’s behavior.
SAF parameters can contain references to variables and expressions. The variables can be predefined variables, variables defined at request time using the set-variable SAF, or variables defined in the server.xml file.
Within the server.xml file itself, a variable can be defined at various levels (for example, <server> and <virtual-server>). As such, the server must have a method for resolving duplicate variable definitions. The server consults the following namespaces (in the following order) when attempting to resolve a variable:
- Predefined variables
- Variables defined at request time through the use of the set-variable SAF
- Virtual Server–specific variables defined at the <virtual-server> level
- Server variables defined at the <server> level
Web Server variables begin with a dollar sign character ($), followed by either upper- or lowercase letters as the next character. Subsequent characters can include any combination of upper- or lowercase alphanumeric characters or underscores (_).
A regular expression notation for variable syntax would be as follows:
Examples of valid variable names include $variable, $Variable, $var_iable, or $var9. Examples of invalid variable names include $_variable and $9variable.
The server.xml file contains definitions for each virtual server contained within the instance, so there is a one-to-many relationship between the server.xml file and virtual servers.
Each virtual server can use a different object configuration file for processing requests. Therefore, there is a one-to-many relationship between an instance and the object configuration file(s), but there is a one-to-one relationship between the virtual server and its object configuration file.
Some changes made through the Administration Console or the command line interface update the appropriate object configuration file. If this file is updated as a result of changes made through either of these two interfaces, you must deploy the updated configuration before the changes are reflected on the appropriate Administration Node(s).
The object configuration file is read when the instance is started or when a dynamic reconfiguration is performed. The syntax for the directives and parameters contained in the object configuration file is validated within the start-up or reconfiguration code base. They are not validated against a schema such as the server.xml file.
Errors found within the file may prevent the instance from starting or processing requests properly.