25.2 The obj.conf FileThe obj.conf file contains the configuration directives that tell the server exactly how to handle client requests. This file has two main functions, corresponding to the two main sections of the file. The first section initializes subsystems, a diverse set of tasks that includes opening and naming log files, loading the MIME types file, loading Java classes and LiveWire applications, and describing logging and directory index formats. The second section contains the object definitions, which tell the server how to handle resource requests. Resource HandlingThe Netscape servers are modeled on the idea that all resources to be served are instances of objects. To tell the server how to treat a set of documents, you assign them to an object. You give an object all of the properties you want the resources to have, including URL mapping, access and authorization, assigning MIME types, logging format, and directory listings. For example, there is no need for a special CGI program directory, since you can assign any document you want to a common cgi object. Subsystem InitializationThe Init directive is used to initialize subsystems of the server. The Init directives for the subsystems being used by the server are grouped at the top of the obj.conf file. They take the following form:
Init fn=function argument1=value1 [argument2=value2 ...] where function is the function name, and the arguments and values depend on the function. Which subsystem is being initialized depends on the value of the fn function. The subsystems and available functions depend on which server you have and the functionality it supports. You may also have your own functions if you have written plug-in applications with the server API. This section lists the Init functions corresponding to basic subsystems used by the server. Functions for Java and LiveWire subsystems commonly appear in this section as well, but they will not be discussed here. cindex-initThe cindex-init function configures fancy directory indexing. These settings apply globally, and cannot be custom configured for specific directories. This function does not turn on fancy indexing for any directory; that is done in the object definitions, if desired. There are four arguments available for this function:
Note that this function does not turn on fancy directory indexing for any directories, but merely configures what a fancy directory would look like if it were turned on. To turn on fancy directory indexing, use the index-common function of the Service directive. init-clfThe init-clf function is used to initialize logging in the common log format. This function tells the server to create one or more common log files and open them to record transactions. Each log file needs to be assigned a name for internal use by the server. The default name for logging (but not for this directive) is global, but you can use whatever name or names you wish. The argument names should be the names you want to use with their values being the absolute paths to the log files. For example, you might want to call your three logs member, newsletter, and global (for everything else). You would do this like so:
Init fn=init-clf member=/https-server/logs/members.log newsletter=/https-server/logs/newsletter.log global=/https-server/logs/access.log (Remember to not break Init directives across lines, despite how this example is formatted.) A more common use would be to create a single general file:
Init fn=init-clf global=/usr/local/etc/httpd/logs/access.log Note that this directive merely initializes the logging system. It does not tell the server to write anything to the log files. That is done by including an AddLog directive in the relevant object, which specifies a logfile name that is defined here. init-uhomeThe init-uhome function tells the server to initialize user directory handling. User directory handling will work perfectly well without this directive, but when used, the user directory locations are pre-cached in a directory table file (by default /etc/passwd) to improve performance. The init-uhome function allows an optional second argument, pwfile, which specifies the name of the user directory table file other than /etc/passwd. A basic initialization would be:
Init fn=init-uhome while one using /usr/local/etc/httpd/users.db as the user table would be:
Init fn=init-uhome pwfile=/usr/local/etc/httpd/users.db load-typesThe load-types function initializes the general MIME-type assignment subsystem. This function loads a types table, the mime.types file. The format of this file is simple, with one record per line:
type/subtype extension1 [extention2 ...] [icon=iconfile] where type/subtype is a MIME type and subtype like text/html, extension is a filename extension such as html, and iconfile is the name of the icon to be shown if a file of that type is listed in a directory index. The icon names should be filenames in the index icon directory (specified by the icon-uri parameter of the cindex-init function). This function can load two different types files, with one flagged as global and the other as local. The global file is given as the value of the mime-types argument, while the local file is defined by the local-types argument. The files may be specified as either absolute paths or file names inside the configuration directory. For example:
Init fn=load-types mime-types=mime.types local-types=clown.types flex-initThis function is used to initialize the more enhanced logging system (called "flexible logging"). The first parameter gives the name of the logfile with the full path to its location. The second parameter is the format parameter, which takes a list of values for the various types of transaction information to log. The filename parameter looks like logname=fullpathname. Then the format parameter will be format.logname=format options. For example, the following line opens and specifies the format of a log named access:
Init fn="flex-init" access="/https-server/logs/access" format.acc ess="%Ses->client.ip% - %Req->vars.auth-user% [%SYSDATE%] \"%Req->reqpb. clf-request%\" %Req->srvhdrs.clf-status% %Req->srvhdrs.content-length%" The lines of the example are broken so poorly to remind you that the directive must be one long line and that all spaces in the format value count. Within the format value, everything between percent signs (%) is a transaction value parameter. Parameters surrounded by \" and "\ are "escaped" because their values may contain spaces. Any characters that are not escaped characters or between percents are literally printed to the logfile, giving your log lines spaces, separators, and readability. Here is the list of log parameter values:
Object ConfigurationThe rest of the object file (beyond the Init directives) consists of a set of objects. Each object comes in a block surrounded by <Object> and </Object> tags. The <Object> tag uses one of two attributes: name, which gives a name to an object, or ppath, which gives a URL path or regular expression for resources belonging to the object. An object consists of a series of directives that specify the behavior of documents within that object. The directives may specify that directory indexing is not allowed, that authentication is required, that the document should be treated as an imagemap, that requests for documents should be logged into a special log file, and so on. An object named research looks like this:
<object name="research"> directive1 directive2 ... </object> Alternatively, you could specify the object by the server path:
<object ppath="/secret/research/*"> directive1 directive2 ... </object> There are two objects included by default: default and cgi. All resources are at first handled by one of these two objects. Directives in the object block may then redirect a specific resource to another named object for handling. In addition, directives within an object may be designated as applying only to (or only not to) specific client hosts (within <client> ... </client> tags). Client-specific directives are the same as other directives, but are wrapped within <client> ... </client> labels. These labels can be qualified using either the dns argument, which matches against the DNS-resolved name for the remote client, or the ip argument, which matches against the IP address itself. Either can be a regular expression. For example, to enable specific directives only within the ora.com domain, you could write:
<client dns=*ora.com> special-directive1 special-directive2 ... </client> As with the Init lines, the object directives take the following form:
directive fn=function argument1=value1 [argument2=value2 ...] where directive is the directive name, function is the function name, and the arguments and values depend on the directive and function. There are only seven directives, and they correspond closely to the request processing pipeline. When a request comes in, it is assigned to an object by matching either a regular expression or the root object. Then:
Within each stage, the directives are processed in the order they appear in the object file. This can lead to occasional problems if you are not careful to put special cases before defaults. AuthTransThe AuthTrans directive is responsible for requesting and interpreting authentication whenever necessary. This directive can use one of two functions: basic-auth or basic-ncsa. Both of these functions mean the same thing. basic-auth is used in 1.x servers. auth-ncsa supersedes it in 2.x servers. The following parameters are used in the AuthTrans directive:
The AuthTrans directive is usually used with the require-auth function of PathCheck. NameTransThe NameTrans directive is responsible for taking the requested server path and determining what actual resource corresponds to it. This includes resolving user directories, URL mapping, and redirections. In addition, the NameTrans directive can assign documents to other objects for further processing. Any of the NameTrans functions, except for redirect, can take an extra argument name that specifies the name of the object to which the document should be transferred. document-rootThis function specifies the root directory of your server's document tree. If no other directive remaps the server path to an absolute path, it will be interpreted as being relative to this directory. The root directory is given as the value of the root argument. For example, to use /usr/local/etc/web/docs/ as the root directory, you would use this setting:
NameTrans fn=document-root root=/usr/local/etc/web/docs/ This function should be used in the default object. home-pageThe Netscape server allows you to assign a special document to the server home page request (i.e., a request for /) using this function. The home page document's path, absolute or relative to the document root, should be given as the value of the argument path. For example, to use /usr/local/etc/web/home.html as the server's home page, you would use this setting:
NameTrans fn=home-page path=/usr/local/etc/web/home.html pfx2dirThis function allows you to remap a server path to a new absolute path by assigning a prefix directory. That is, you can say that a whole server path tree actually resides at the end of a branch of another tree. This function takes two arguments:
redirectThis function allows the server to redirect the user to a resource's location if it has moved. It uses the following arguments:
unix-homeThis function sets up user directories with the following arguments:
PathCheckThe PathCheck directive tells the server to check various things about the translated path. This may be a security check to identify any suspicious directories, a scan for CGI path info spackled onto the end of an otherwise perfectly good path, or an instruction to require authentication. PathCheck's functions are less clearly unified than those of the other directives, but they have the common need to be applied after the path has been translated but before the processing of the request's content begins. deny-existenceThis function is used to hide the existence of a file from the user. It can take two arguments:
find-indexWhen a user requests a directory, instead of a plain file, the server can either send a specified index file or create a directory listing (if enabled and authorized). The find-index function enables this ability. There is only one argument to this function:
find-linksThis function allows you to specify when hard or soft links will be followed as part of path resolution. There are potential security problems with allowing links to be followable. If a request comes in for the path you have listed, the server will check for symbolic links that you don't want to be accessed, and if it finds any in the directory, it returns an error. Two parameters are used with this function:
This example disables all symbolic links in user directories:
PathCheck fn=find-links dir=public_html disable=hs find-pathinfoWhen a user requests a document, he can put extra information (which may or may not get used) onto the end of the document's server path in the form of additional directory levels. In a CGI environment, this is what makes up the PATH_INFO variable. The Netscape server does not identify and strip out this information by default, which means if you want it to do so, you have to tell it to. The find-pathinfo function does just that. There are no arguments. To handle path info correctly, just include this directive:
PathCheck fn-find-pathinfo require-authThis function tells the server that it must be able to authenticate the user before any further processing can take place. If the authentication information has already been sent, this function causes it to be used. If it has not been sent, the user will be prompted for a user name and password which will be returned to your server. The following arguments are used:
For example:
PathCheck fn=require-auth auth-type=realm realm="web" auth-user=(linda|val|stephen) unix-uri-cleanUsers may try to break out of your server's document space by inserting extraneous path elements into their server paths. The unix-uri-clean function looks for /../, /./, and //, and denies access if any of them are present. There are no parameters.
PathCheck fn=unix-uri-clean Remember that all PathCheck functions will be applied in order, so if your path info may contain these, you should make sure the find-pathinfo function is listed before the unix-uri-clean function. load-configThis function tells the server to look for local configuration files in document directories. Local configuration files use obj.conf configuration directives to apply localized configuration options to specific directories. The following parameters are used:
check-aclThis function tells the server to check a specific access control list for authorization requirements on the requested object. Access control lists (ACLs) are contained in sections of the ACLFile, which is set in magnus.conf. The function is executed before any require-auth settings in PathCheck. The following parameters can be used:
ObjectTypeThe ObjectType directive is used to tell the server how to assign a MIME type, encoding, and/or language to an object. This may be by looking up the extension in the mime.types file or by forcing it directly. Unlike some other directives, multiple ObjectType directives do not override each other, but fortify each other. If one sets the MIME type and another sets the encoding, fine. If, however, one sets the type and another tries to set it again, the second loses rather than the first. In addition, like many servers, the Netscape servers use several "magic" MIME types to cause special treatment to occur. They are called internal server types, but they are the same as magic types. force-typeThis function sets the MIME type by fiat. It may optionally also set the encoding and/or language.
For example, to make the type text/plain the default for a given object, you would add the following directive after all the other ObjectType directives:
ObjectType fn=force-type type=text/plain type-by-expThis function tells the server to assign a given type if the translated path matches a given regular expression. As with the force-type function, the server may also set the encoding and/or language.
For example, to tell the server that everything in the directory /scratch-n-sniff/ should be assigned the type odor/oif, regardless of extensions, you could use this directive:
ObjectType fn=type-by-exp type=odor/oif exp=/scratch-n-sniff/* type-by-extensionRather than having to use a special ObjectType directive for every file type, you can set up most of them in a mime.types file in advance and use the type-by-extension function to have the server look the file type up. This lookup is done based on the document's extension, which explains the name of this directive. There are no arguments; you simply use:
ObjectType fn=type-by-extension image-switchThis function allows you to send the client an image of a different type, if it exists in the directory, when the client can't accept a certain image type. For example, if a user requests image.gif, and there is also image.jpg in the same directory, the server will send the JPEG instead. There are no parameters for this function. ServiceThe Service directive is where the server finally gets down to business and does something material to respond to a request. Up until now, the server has checked paths, remapped them, checked them again, and picked some MIME types. With the Service directive, it will finally decide what to do with the file it has found. Since an applicable Service directive tells the server how to handle a request, further Service directives are ignored, unless the first uses the append-trailer function. Any Service function can take either (or none) of two constraint arguments. The type argument can take a regular expression to match against the MIME type. If this argument is present and it doesn't match, that Service directive is deemed inapplicable and the next one is tried. Similarly, the method argument, if present, must match the request method for the directive to apply. The value is GET, HEAD, or POST, or any combination delimited by vertical bars (|) within parentheses. For example, (GET|HEAD) will match GET requests and HEAD requests, but not POST requests. append-trailerappend-trailer is the only Service function that does not actually send data to the client. Instead, it merely tells the server that when it does send data, it should append a fragment of HTML to any HTML file it does send.
For example, to append the string "Copyright ©1996" to the end of every file, you would use this directive:
Service fn=append-trailer type=text/html trailer="Copyright ©1996" imagemapThis function tells the server to process a request as an imagemap with type=magnus-internal/imagemap:
Service type=magnus-internal/imagemap fn=imagemap index-commonThis function generates a fancy directory index. Much of the format is controlled not here, but by the cindex-init function of the Init directive. What is controlled here is whether to build one (that is, whether this function is used) and what header and footer files to use, if any. The type given in this directive is type=magnus-internal/directory. You may also use the following parameters:
index-simpleThis function tells the server to produce a simple directory index. This does not include icons, sizes, etc., but only a bulleted list of linked file names. As with index-common, this function uses type=magnus_internal/directory. parse-htmlThis function is used to serve server-side include files. query-handlerSpecifies a CGI program to act as a handler for non-CGI GET requests that include a query string. As such, it is only seen as applicable if the request matches those criteria. The program should be given as an absolute path in the path argument. For example, to use /l0/cgi-bin/doc_searcher, you would use this setting:
Service fn=query-handler path=/l0/cgi-bin/doc_searcher This program is executed with the original document path stored in the PATH_INFO CGI variable. send-cgiThis function tells the server to execute a requested object as a CGI program. For example, an object that runs everything in the server path /cgi-bin/ would be:
<object ppath=/cgi-bin/> Service fn=send-cgi </object> send-errorThis function sends a specified file when an error occurs. The absolute path to the file should be given in the path argument. send-fileThis function tells the server to send the file. It is often useful to provide this as a default behavior by adding this directive after all other Service directives:
Service method(GET|HEAD) fn=send-file ErrorThe Error directive is where the server confesses to being unable to complete a request. It can use the same functions as the Service directive, but it is only used when an error has occurred, and it has different constraint arguments, reason and code, which correspond to the textual description of the error and the status code, respectively. You cannot place both code and reason in the same Error directive. There are four sets of values:
send-errorThis function sends a specified file to the user when an error occurs. The absolute path to the file should be given in the path argument. query-handlerYou may want to use a CGI program to customize a response resulting from an error. Use the query-handler function to specify a CGI file (with the path parameter) for a given error code. AddLogThe AddLog directive is applied after the server has handled the request and is purely for local bookkeeping. Its functions let you write a normal transaction log and record what user-agent was responsible for the transaction. If you have more than one, all AddLog directives in an object will be used. common-logThis function is used to record transaction data in the common NCSA log format. This is the format used by most log analysis tools. It uses the following parameters:
flex-logThis function tells the server to log transaction data in the extended or flexible logging format. This format is specified in the Init directives with the flex-init function. It uses the same parameters as the common-log function:
record-useragentThis function tells the server to write the client IP address followed by the value of the User-Agent header into a log file. As with the common-log function, the argument name tells the server which log file to write to. If it is omitted, the information will be written to the global access log. |
|