obj.conf
configuration file contains directives that instruct the Enterprise Server how to handle requests from clients. This chapter discusses server instructions in obj.conf
; the use of OBJECT
and CLIENT
tags; the flow of control in obj.conf
; and the syntax rules for editing obj.conf
.
The sections in this chapter are:
obj.conf
file contains two kinds of directives:
OBJECT
tags.
OBJECT
tags.
Directive fn=func-name name1="value1"...nameN="valueN"For example:
NameTrans fn="document-root" root="D:/Netscape/Server4/docs"
Directive
indicates when this instruction is executed, which is either during server initialization or during a step in the request handling process. If it is to be executed during server initialization, the value is Init
. Otherwise the value is one of AuthTrans
, NameTrans
, PathCheck
, ObjectType
, Service
, Error
, and AddLog
.
The value of the fn
argument is the name of the Server Application Function to execute. All directives must supply a value for the fn
parameter -- if there's no function, the instruction won't do anything.
The remaining parameters are the arguments needed by the function, and they vary from function to function.
Enterprise Server is shipped with a set of built-in server application functions (SAFs) such as load-types
, basic-auth
, and so on, that you can use to create and modify directives in obj.conf
. You can also define new SAFs, as discussed in Chapter 4, "Creating Custom SAFs.".
Init fn="load-types" mime-types="mime.types"
This example calls the function load-types
to load the file mime.types
, which the server will use for looking up MIME types.AuthTrans fn=basic-auth userfn=ntauth auth-type=basic userdb=none
This example calls the basic-auth
function, which calls a custom function (in this case ntauth
, to verify authorization information sent by the client. The Authorization header is sent as part of the basic server authorization scheme.NameTrans fn="document-root" root="D:/Netscape/Server4/docs"
This example calls the document-root
function with a root
argument of "D:/Netscape/Server4/docs"
. The function document-root
function translates the "http://
server_name/"
part of the requested to URL to the document root, which in this case is D:/Netscape/Server4/docs
. Thus a request for http://
server-name/doc1.html
is translated to D:/Netscape/Server4/docs/doc1.html
.NameTrans
step. In general, these tests determine whether the path is valid and whether the client is allowed to access the requested resource. For example:
PathCheck fn="find-index" index-names="index.html,home.html"
This example calls the find-index
function with an index-names
argument of "index.html,home.html"
. If the requested URL is a directory, this function instructs the server to look for a file called either index.html
or home.html
in the requested directory.type
(which indicates content type), encoding
and language
. The MIME type is sent in the headers of the response to the client. The MIME type also helps determine which Service
directive the server should execute.
The resulting type may be:text/html"
or "image/gif"
(for example, the file name extension .gif
translates to the MIME type "image/gif"
).magnus-internal".
ObjectType fn="type-by-extension"
This example calls the type-by-extension
function which causes the server to determine the MIME type according to the requested resource's file extension.send-file
function to send the contents of the requested file along with the appropriate header files to the client.
The default Service
directive is:
Service method="(GET|HEAD|POST)" type="*~magnus-internal/*"
fn="send-file"
This directive instructs the server to call the send-file
function in response to any request whose method is GET
, HEAD
, or POST
, and whose type
does not begin with magnus-internal/
. (Note the use of the special characters *~
to mean "does not match".)
Another example is:
Service method="(GET|HEAD)" type="magnus-internal/imagemap" fn="imagemap"
In this case, if the method of the request is either GET
or HEAD
, and the type of the requested resource is "magnus-internal/imagemap"
, the function imagemap
is called.AddLog fn="flex-log" name="access"
This example calls the flex-log
function to log information about the current request in the log file named access
.Error fn="send-error" reason="Unauthorized"
path="D:/netscape/server4/errors/unauthorized.html"
In this example, the server sends the file in "D:/netscape/server4/errors/unauthorized.html"
whenever a client requests a resource that it is not authorized to access.Object
and Client
tags in the file obj.conf
. Object
tags group together directives that apply to requests for particular resources, while Client
tags group together directives that apply to requests received from particular clients.
obj.conf
file are grouped into objects that begin with an <Object>
tag and end with a </Object>
tag. The default object provides instructions to the server about how to process requests by default. Each new object modifies the default object's behavior.
An Object
tag may have a name
attribute or a ppath
attribute. Either parameter may be a wildcard pattern. For example:
<Object name="cgi">or
<Object ppath="/usr/netscape/server4/docs/private/*">The server always starts handling a request by processing the directives in the default object. However, the server switches to processing directives in another object after the
NameTrans
stage of the default object if either of the following conditions is true:
NameTrans
directive specifies a name
argument
NameTrans
stage matches the ppath
attribute of another object
Service
stage) as soon as one is successfully executed, whereas for other stages the server processes all directives in that stage, including the ones in the default object as well as those in the additional object. For more details, see the section "Flow of Control in obj.conf."
NameTrans
directive in the default object specifies a name
argument, the server switches to processing the directives in the object of that name before processing the remaining directives in the default object.
For example, the following NameTrans
directive in the default object assigns the name cgi
to any request whose URL starts with http://
server_name/cgi/
.
<Object name="default">When that
NameTrans fn="pfx2dir" from="/cgi" dir="D:/netscape/server4/docs/mycgi" name="cgi"
...
</Object>
NameTrans
directive is executed, the server starts processing directives in the object named cgi
:
<Object name="cgi">
more directives...
</Object>
NameTrans
directives in the default object, the logical URL of the request will have been converted to a physical pathname. If this physical pathname matches the ppath
attribute of another object in obj.conf
, the server switches to processing the directives in that object before processing the remaining ones in the default object.
For example, the following NameTrans
directive translates the http://
server_name/
part of the requested URL to D:/Netscape/Server4/docs/
(which is the document root directory).
<Object name="default">
NameTrans fn="document-root" root="D:/Netscape/Server4/docs"
...
</Object>The URL
http://
server_name/internalplan1.html
would be translated to D:/Netscape/Server4/docs/internalplan1.html
. However, suppose that obj.conf
contains the following additional object:
<Object ppath="*internal*">In this case, the partial path
more directives...
</Object>
*internal*
matches the path D:/Netscape/Server4/docs/
internal
plan1.html.
So now the server starts processing the directives in this object before processing the remaining directives in the default object.
<Client>
tag may be used within an object to limit a group of directives to requests received from specific clients. Directives between a <Client>
tag and a matching </Client>
tag are executed only if the client's information matches the <Client>
parameters.
A <Client>
tag may have parameters for ip
, dns
, and/or host
. The value of these parameters are wildcard patterns. For example:
<Client ip="198.95.251.*">or
<Client dns="*.netscape.com">The directives in the
<Client>
block are only executed if the client that sent the current request matches all the parameters.
The ip
parameter is the IP address of the client. The dns
parameter is the DNS name of the client.
The host
parameter is typically used to configure "software virtual servers." These are multiple "virtual" servers on the same machine. There is really only one web server running on the machine, but there may be many DNS names which map to the machines IP address. The web server can tell which "virtual" server was requested because clients such as Netscape browsers includes a "Host" header in the request which tells the DNS name of the server that the user requested.
obj.conf
.
magnus.conf
, then executes the Init
directives in obj.conf
. The Init
section contains directives that initialize the server, such as loading and initializing additional modules and plugins, and initializing log files.
The server executes all the directives in the Init
section.
The Init
section should always contain a directive that invokes the load-types
function. This function loads the MIME types file that the server uses to create a table that maps file extensions to MIME types. The file is usually called mime.types
. We don't recommend that you change the name of the MIME types file since most people expect it to be called mime.types
. The following directive loads the MIME types file:
Init fn="load-types" mime-types="mime.types"The most common way that the server determines the MIME type of a requested resource is by invoking the
type-by-extension
directive in the ObjectType
section of obj.conf
. This function will not work if the MIME types file has not been loaded.
AuthTrans
directives in the default object to check that the client is authorized to access the server.
If there is more than one AuthTrans directive, the server executes them all (unless one of them results in an error). If an error occurs, the server skips all other directives except for Error
directives.
NameTrans
directive in the default object to map the logical URL of the requested resource to a physical pathname on the server's file system. The server looks at each NameTrans
directive in the default object in turn, until it finds one that can be applied.
If there is more than one NameTrans
directive in the default object, the server considers each directive until one succeeds.
The NameTrans
section in the default object must contain exactly one directive that invokes the document-root
function. This functions translates the http://
server_name/
part of the requested URL to a physical directory that has been designated as the server's document root. For example:
NameTrans fn="document-root" root="D:/Netscape/Server4/docs"The directive that invokes
document-root
must be the last directive in the NameTrans
section so that it is executed if no other NameTrans
directive is applicable.
The pfx2dir
(prefix to directory) function is used to set up additional mappings between URLs and directories. For example, the following directive translates the URL http://
server_name/cgi/
into the directory pathname D:/netscape/server4/docs/mycgi/:
NameTrans fn="pfx2dir" from="/cgi" dir="D:/netscape/server4/docs/mycgi"Notice that if this directive appeared after the one that calls
document-root
, it would never be executed, with the result that the resultant directory pathname would be D:/netscape/server4/docs/cgi/ (not mycgi
). This illustrates why the directive that invokes document-root
must be the last one in the NameTrans
section.
NameTrans
directive, the server might start processing directives in another object. This happens if the NameTrans
directive that was successfully executed specifies a name or generates a partial path that matches the name
or ppath
attribute of another object.
If the successful NameTrans
directive assigns a name by specifying a name
argument, the server starts processing directives in the named object (defined with the OBJECT
tag) before processing directives in the default object for the rest of the request handling process.
For example, the following NameTrans
directive in the default object assigns the name cgi
to any request whose URL starts with http://
server_name/cgi/
.
<Object name="default">When that
...
NameTrans fn="pfx2dir" from="/cgi" dir="D:/netscape/server4/docs/mycgi" name="cgi"
...
</Object>
NameTrans
directive is executed, the server starts processing directives in the object named cgi
:
<Object name="cgi">When a
more directives...
</Object>
NameTrans
directive has been successfully executed, there will be a physical pathname associated with the requested resource. If the resultant pathname matches the ppath
(partial path) attribute of another object, the server starts processing directives in the other object before processing directives in the default object for the rest of the request handling process.
For example, suppose obj.conf
contains an object as follows:
<Object ppath="*internal*">Now suppose the successful
more directives...
</Object>
NameTrans
directive translates the requested URL to the pathname D:/Netscape/Server4/docs/internalplan1.html
. In this case, the partial path *internal*
matches the path D:/Netscape/Server4/docs/
internal
plan1.html.
So now the server would start processing the directives in this object before processing the remaining directives in the default object.
NameTrans
step, the server executes PathCheck
directives to verify that the client is allowed to access the requested resource.
If there is more than one PathCheck
directive, the server executes all the directives in the order in which they appear, unless one of the directives denies access. If access is denied, the server switches to executing directives in the Error section.
If the NameTrans
directive assigned a name or generated a physical pathname that matches the name
or ppath
attribute of another object, the server first applies the PathCheck
directives in the matching object before applying the directives in the default object.
PathCheck
directives all approve access, the server next executes the ObjectType
directives to determine the MIME type of the request. The MIME type has three attributes: type, encoding, and language. When the server sends the response to the client, the type, language, and encoding values are transmitted in the headers of the response. The type
also frequently helps the server to determine which Service
directive to execute to generate the response to the client.
If there is more than one ObjectType
directive, the server applies all the directives in the order in which they appear. However, once a directive sets an attribute of the MIME type, further attempts to set the same attribute are ignored. The reason that all ObjectType
directives are applied is that one directive may set one attribute, for example type
, while another directive sets a different attribute, such as language
.
As with the PathCheck
directives, if another object has been matched to the request as a result of the NameTrans
step, the server executes the ObjectType
directives in the matching object before executing the ObjectType
directives in the default object.
type-by-extension
function. This function instructs the server to look up the MIME type according to the requested resource's file extension in the MIME types table. This table was created during the Init
stage by the load-mime-types
function, which loads the MIME types file, (which is usually called mime.types)
.
For example, the entry in the MIME types table for the extensions .html
and.htm
is usually:
type=text/html exts=htm,htmlwhich says that all files that have the extension
.htm
or .html
are text files formatted as HTML and the type
is text/html
.
Note that since the server creates the MIME types table during initialization, if you make changes to the MIME types file, you must restart the server before those changes can take effect.
For more information about MIME types, see Appendix C, "MIME Types."
ObjectType
directive has set the type, and the server does not find a matching file extension in the MIME
types table, the type
still has no value even after type-by-expression
has been executed. Usually if the server does not recognize the file extension, it is a good idea to force the type to be text/plain
, so that the content of the resource is treated as plain text. There are also other situations where you might want to set the type regardless of the file extension, such as forcing all resources in the designated CGI directory to have the MIME type magnus-internal/cgi
.
The function that forces the type is force-type
.
For example, the following directives first instruct the server to look in the MIME types table for the MIME type, then if the type
attribute has not been set (that is, the file extension was not found in the MIME types table), set the type
attribute to text/plain
.
ObjectType fn="type-by-extension"If the server receives a request for a file
ObjectType fn="force-type" type="text/plain"
abc.dogs
, it looks in the MIME types table, does not find a mapping for the extension .dogs
, and consequently does not set the type
attribute. Since the type
attribute has not already been set, the second directive is successful, forcing the type
attribute to text/plain
.
The following example illustrates another use of force-type
. In this example, the type
is forced to magnus-internal/cgi
before the server gets a chance to look in the MIME types table. In this case, all requests for resources in http://
server_name/cgi/
are translated into requests for resources in the directory D:/netscape/server4/docs/mycgi/. Since a name is assigned to the request, the server processes ObjectType
directives in the object named cgi
before processing the ones in the default object. This object has one ObjectType
directive, which forces the type
to be magnus-internal/cgi
.
NameTrans fn="pfx2dir" from="/cgi" dir="D:/netscape/server4/docs/mycgi" name="cgi"
<Object name="cgi">The server continues processing all
ObjectType fn="force-type" type="magnus-internal/cgi"
Service fn="send-cgi"
</Object>
ObjectType
directives including those in the default object, but since the type
attribute has already been set, no other directive can set it to another value.
Service
directive to generate the response to send to the client. The server looks at each Service
directive in turn, to find the first one that matches the type, method and query string. If a Service
directive does not specify type, method, or query string, then the unspecified attribute matches anything.
If there is more than one Service
directive, the server applies the first one that matches the conditions of the request, and ignores all remaining Service
directives.
As with the PathCheck
and ObjectType
directives, if another object has been matched to the request as a result of the NameTrans
step, the server considers the Service
directives in the matching object before considering the ones in the default object. If the server successfully executes a Service
directive in the matching object, it will not get round to executing the Service
directives in the default object, since it only executes one Service
directive.
Service
directives work, consider what happens when the server receives a request for the URL D:/
server_name/jos.html
. In this case, all directives executed by the server are in the default object.
NameTrans
directive translates the requested URL to D:/netscape/server4/docs/jos.html
:NameTrans fn="document-root" root="D:/Netscape/Server4/docs"
PathCheck
directives all succeed.ObjectType
directive tells the server to look up the resource's MIME type in the MIME types table:ObjectType fn="type-by-extension"
type=text/html exts=htm,html
Service
directive. The value of the type
parameter matches anything that does not begin with magnus-internal/
. (For a list of all wildcard patterns, see Appendix D, "Wildcard Patterns.") This directive sends the requested file, jos.html
, to the client.Service method="(GET|HEAD|POST)" type="*~magnus-internal/*"For an example that involves using another object, consider what happens when the server receives a request for
fn="send-file""
http://
server_name/servlet/doCalculation.class
. This example assumes that servlets have been activated and the directory D://netscape/server4/docs/servlet/
has been registered as a servlet directory (that is, the server treats all files in that directory as servlets).
NameTrans fn="pfx2dir" from="/servlet"
dir="D:/Netscape/Server4/docs/servlet" name="ServletByExt"
name
assignment, the server switches to processing the directives in the object named ServletByExt
. This object is defined as:<Object name="ServletByExt">
ObjectType fn="force-type" type="magnus-internal/servlet"
Service type="magnus-internal/servlet" fn="NSServletService"
</Object>
ServletByExt
object has no PathCheck
directives, so the server processes the PathCheck
directives in the default object. Let's assume that all PathCheck
directives succeed.ObjectType
directives, starting with the one in the ServletByExt
object. This directive sets the type
attribute to magnus-internal/servlet
.ObjectType fn="force-type" type="magnus-internal/servlet"
ObjectType
directives in the default object, but since the type
attribute is already set its value cannot be changed.Service type="magnus-internal/servlet" fn="NSServletService"
type
argument of this directive matches the type
value that was set by the ObjectType
directive. So the server goes ahead and executes this Service
directive which calls the NSServletService
function. This function invokes the requested file as a servlet and sends the output from the servlet as the response to the client. (If the requested resource is not a servlet, an error occurs.)Service
directive has now been executed, the server does not process any other Service
directives. (However, if the matching object had not had a Service
directive that was executed, the server would continue looking at Service
directives in the default object.)Service
directive that does the default thing (sends a file) if no other Service
directive matches a request sent by a browser. This default directive should come last in the list of Service
directives in the default object, to ensure it only gets called if no other Service
directives have succeeded. The default Service
directive is usually:
Service method="(GET|HEAD|POST)" type="*~magnus-internal/*"This directive matches requests whose method is
fn="send-file"
GET
, HEAD
, or POST
, which covers nearly virtually all requests sent by browsers. The value of the type
argument uses special pattern-matching characters. For complete information about the special pattern-matching characters, see Appendix D, "Wildcard Patterns.".
The characters "*~
" mean "anything that doesn't match the following characters", so the expression "*~magnus-internal/
" means "anything that doesn't match "magnus-internal/
". An asterisk by itself matches anything, so the whole expression "*~magnus-internal/*
" matches anything that does not begin with "magnus-internal/
".
So if the server has not already executed a Service
directive when it reaches this directive, it executes the directive so long as the request method is GET
, HEAD
or POST
, and the value of the type
attribute does not begin with "magnus-internal/
". The invoked function is send-file
, which simply sends the contents of the requested file to the client.
AddLog
directives to add entries to the log files.
All AddLog
directives are executed. The server can add entries to multiple log files.
Depending on which log files are used and which format they use, the Init
section may need to have directives that initialize the logs. For example, if one of the AddLog
directives calls flex-log
, which uses the extended log format, the Init
section must contain a directive that invokes flex-init
to initialize the flexible logging system.
For more information about initializing logs, see the discussion of the functions flex-init
and init-clf
in Chapter 3, "Predefined SAFS for Each Stage in the Request Handling Process."
PathCheck
or AuthTrans
directive denies access to the requested resource, or the requested resource does not exist, then the server immediately stops executing all other directives and immediately starts executing the Error
directives.
obj.conf
file. Be very careful when editing this file. Simple mistakes can make the server fail to start or operate incorrectly.
obj.conf
. The outcome of some directives affect the execution of other directives.
For PathCheck
directives, the order within the PathCheck
section is not so important, since the server executes all PathCheck
directives. However, in the ObjectType
section the order is very important, because if an ObjectType
directive sets an attribute value, no other ObjectType
directive can change that value. For example, if the default ObjectType
directives were listed in the following order (which is the wrong way round), every request would have its type
value set to text/plain
, and the server would never have a chance to set the type
according to the extension of the requested resource.
ObjectType fn="force-type" type="text/plain"Similarly, the order of directives in the
ObjectType fn="type-by-extension"
Service
section is very important. The server executes the first Service
directive that matches the current request and does not execute any others.
obj.conf
file are case-sensitive including function names, parameter names, many parameter values, and path names.
/
) rather than back-slashes (\
) in path names under Windows NT. Back-slash escapes the next character.
obj.conf
, then use the Server Manager interface to make changes to your server, the Server Manager will wipe out your comments when it updates obj.conf
.
Last Updated: 08/12/99 14:32:25
Copyright © 1999 Netscape Communications Corporation