caucho
Resin
FAQ
Reference Guide
Demo
Tutorial

Getting Started
Configuration
IDE
Topics
JSP
XML/XSLT

Basic Config
Directory
Servlets
Filters
Resources
Databases
Messaging
Security Config
Log Config
Taglib Config
Misc resin.conf
Host resin.conf
Port resin.conf
App resin.conf
Summary
Glossary
Index
 Servlet and Host Configuration

Misc resin.conf
Configuration
Port resin.conf

HTTP and Srun configuration is identical except for load balancing (srun and srun-backup.)

HTTP configuration follows the Servlet 2.2 deployment descriptors. The nesting depth is important, but order is generally not important. In the sections that follow, the section header tells where the attribute belongs. For example, the servlet-mapping configuration in caucho.com/http-server/host/web-app looks like:

<caucho.com>
  <http-server>
    <host id=''>
      <web-app id='/'>
        <servlet-mapping url-pattern='/test' .../>
      </web-app>
    </host>
  </http-server>
</caucho.com>

Most of the interesting configuration belongs in web-app. For example, servlet-mapping belongs in a web-app element, but thread-max belongs in the top-level http-server element.

The server contains a number of host elements and each host contains web-app elements. Each host configures a virtual host and each web-app configures an application.

Full Configuration
<caucho.com>
<http-server>
  <host id='gryffindor.caucho.com' app-dir='gryffindor'>
    <web-app id='/'>
      <servlet-mapping .../>
      ...
    </web-app>
    
    <web-app id='/test' app-dir='/usr/local/test'>
      ...
    </web-app>
  </host>
  
  <host id='slytherin.caucho.com' app-dir='slytherin'>
    ...
  </host>

  ...
</http-server>
</caucho.com>

Index
access-logSpecifies the access log file
alternate-session-url-prefixConfigures an alternate URL prefix to be used for /~J=xxx/test
cacheActivates the memory cache with a specified size
doc-dirSpecifies the document directory for the <host> or <http-server>
error-logSpecifies the file for error logging
error-pageThe url to display if the web server can't connect to Resin
forbid-hostSelects a list of IPs that are forbidden
global-system-propertiesDetermines if system-properties are classloader specific or global
hostDefines a virtual host
httpDefines a HTTP or SSL port for the standalone server
http-serverConfiguration for the servlet engine
ignore-client-disconnectIgnores ClientDisconnectionExceptions thrown when the browser disconnects
pingSpecifies a list of URLs to test to check the webserver's uptime
root-dirSpecifies the root directory for the <host> or <http-server>
server-listenerSpecifies the classname for a listener when the server starts and shuts down
server-nameDefines the canonical url for the host
servlet-classloader-hackEnables the Servlet specification classloader hack
session-cookieConfigures session cookie
session-url-prefixConfigures the URL prefix to be used for url-rewriting
srunDefines multiple client machines for load balancing
srun-backupDefines backup client machines for load balancing
sticky-sessionsEnables or disables sticky-session load balancing
thread-keepaliveNumber of threads to be used in keepalive requests
thread-maxMaximum number of request-handling threads
url-character-encodingDefines the character encoding to be used for decoding the URL
url-length-maxSpecifies the maximum length allowed in a HTTP URL
war-dirSpecifies a special directory to place war files
war-expand-dirSpecifies the destination of war expansion
web-appSpecifies an application

http-server

http-server

Configuration for the servlet engine.

Any <resource-ref> resource configured in <http-server> is shared for all virtual hosts and web-apps in the server. So a database or EJB server configured in the <http-server> will be shared for all virtual hosts.

Default application tags like <servlet-mapping> may appear in the <http-server> section. These tags will be defaults for the contained <web-app> and <host>.

alternate-session-url-prefix

Configures an alternate URL prefix to be used for /~J=xxx/test.jsp style url-rewriting. There is no default.

If alternate-session-url-prefix is configured, URL rewriting will add the session to the beginning of the URL as a path prefix instead of the standard ;jsessionid= suffix. For clients like mobile devices with limited memory, this will allow careful web designers to minimize the page size.

...
<http-server>
  <alternate-session-url-prefix>/~J=</alternate-session-url-prefix>
  ...

cache

Activates the memory cache with a specified size. Resin's cache acts as a proxy cache. Pages with expires headers will be cached, avoiding expensive Java or Database processing.

To activate caching, you must add a cache directive. By default, caching is disabled.

The cache combines memory and file caching. The most referenced pages are served out of memory and the rest are served from the filesystem.

AttributeMeaningDefault
dirFile directory to store the cached pagesresin1.2/cache
entriesNumber of entries allowed in the memory cache16386
sizeSize in kilobytes of the memory1024
enabletrue or false to disabletrue

For example, a page created by several sophisticated and slow database queries may only change every 15 minutes. If that page sets its expires header, Resin can serve the generated page as fast as a static page.

Default: by default, cache is disabled.

error-log

Specifies the file for error logging. The log is relative to $RESIN_HOME. You can use the special path $app-dir to make the log relative to the host, e.g. $app-dir/WEB-INF/log/access.log.

<caucho.com>
<http-server error-log='log/error.log'>

<host id='foo.com' error-log='log/foo.log'>
 ...
</host>

</http-server>
</caucho.com>

error-log attributes
AttributeMeaningDefault
encodingcharacter encodingThe JVM's default
hrefThe log's filenamerequired
rollover-periodHow often the log should be rotatednever
rollover-sizeHow large the log can be before rotatinginfinite
timestampFormat for a timestamp before each entrynone

Default: By default, a host's error log will use an error-log defined in http-server.

error-page

The url to display if the web server can't connect to Resin. This is a special case of error-page in the web-app configuration.

The Apache and IIS plugins use this special error-page directive to display a custom error page when the web server can't connect to Resin. The location must be an absolute path understandable to the web server.

<caucho.com>
  <http-server>
    <error-page exception-type='connection'
                location='/connection_error.html'/<>
  </http-server>
</caucho.com>

forbid-host

Selects a list of IPs that are forbidden.

<http-server>
  <forbid-host>192.168.0.1</forbid-host>
  <forbid-host>192.168.0.2</forbid-host>
  ...
</http-server>

forbid-host is implemented by com.caucho.http.security.ForbidHost. It is stored in JNDI as java:comp/env/caucho/forbid-host. An intelligent log might detect a denial of service attack and dynamically forbid the host.

ignore-client-disconnect

Ignores ClientDisconnectionExceptions thrown when the browser disconnects.

<caucho.com>
  <http-server>
    <ignore-client-disconnect>false</ignore-client-disconnect>

    ...
  </http-server>
</caucho.com>

False by default, throws exceptions on disconnects.

global-system-properties

Determines if system-properties are classloader specific or global.

By default, Resin's web-apps and hosts have isolated system properties. So System.getProperty("test") in host foo.com might return a different value from System.getProperty("test") in host bar.com. Usually, this is the correct solution to prevents hosts and web-apps from affecting each other. Specialized applications may want to disable this feature however.

...
<http-server>
  <global-system-properties>true</global-system-properties>
  ...
</http-server>

Default: The default value is false.

host

Defines a virtual host. If no hosts are specified, or if a request doesn't match a host, configuration in http-server will be used instead.

The id may contain a list of hosts. Any host in the list will match.

See application configuration for servlet configuration.

Hosts can use regexp instead of id to dynamically create new hosts.

AttributeMeaningDefault
idThe host namerequired
regexpA regular expression matching hosts.none
app-dirThe root directory of the host (can use replacement vars) use http-server app-dir

Any <resource-ref> resource configured in <http-server> is shared for all virtual hosts and web-apps in the server. So a database or EJB server configured in the <http-server> will be shared for all virtual hosts.

Default application tags like <servlet-mapping> may appear in the <http-server> section. These tags will be defaults for the contained <web-app> and <host>.

<caucho.com>
<http-server>

<host id='www.foobar.com, foobar.com'
      app-dir='foobar/docs'>
  <web-app id='/'>
    <servlet-mapping url-pattern='/servlets/*'
                     servlet-name='invoker'/> 
  </web-app>
</host>

<host regexp='([^.]*).users.com'
      app-dir='/home/$1/public_html'>
  ...
</host>


</http-server>
</caucho.com>

Note: Only the Resin Java process understands regexps. Because mod_caucho, isapi_srun and the other web server plugins don't understand the regexps, you may need to do additional work to make the web server send the request to Resin.

Default: If the id attribute is null or '*', the <host> will be used as the default configuration for any virtual host that doesn't match a specific <host> block.

http

Defines a HTTP or SSL port for the standalone server.

AttributeMeaning
idhttp identifier name
hostThe listening host
portThe listening port
virtual-hostVirtual host to select a host block.
sslenable ssl
key-store-typeJSSE Type of the key store (default jks)
key-store-fileJSSE File containing the certificates
key-store-passwordJSSE Password to read the certificates
certificate-fileOpenSSL certificate (Resin 2.0.5)
certificate-key-fileOpenSSL key certificate (Resin 2.0.5)
certificate-key-passwordOpenSSL key password (Resin 2.1.1)
crypto-deviceOpenSSL engine (Resin 2.0.5)
thread-maxMaximum number of live threads.200
thread-minMinimum number of live threads.5
thread-keepaliveNumber of keepalive threads100
request-timeoutMax time for a request, after this the request will be interrupted.30 sec
listenValue of the socket listen parameter5
accept-buffer-sizeNumber of sockets in the accept buffer.256
shutdown-wait-timeHow long to wait for connections to finish before exiting.10 sec.
Basic HTTP configuration
<caucho.com>
  <http-server>
    <http port='8080'>
    ...
  </http-server>
</caucho.com>
JSSE configuration
<caucho.com>
  <http-server>
    <http port='8443'>
      <ssl>true</ssl>
      <key-store-type>pkcs12</key-store-type>
      <key-store-file>keys/server.p12</key-store-file>
      <key-store-password>changeit</key-store-password>
    </http>
    ...
  </http-server>
</caucho.com>

ping

Specifies a list of URLs to test to check the webserver's uptime. Ping adds reliability to a web site. It launches a separate thread to check if a list of URLs return valid results, i.e. HTTP status 200. If the URLs fail after repeated attempts, Resin will exit. The parent process, either wrapper.pl or the NT service, will automatically restart Resin.

Because the ping thread is in the same JVM as the web server, ping cannot detect all failure types. In particular, if the JDK itself freezes, ping can do nothing. It can detect problems like deadlocks or database connection overflows or memory leaks.

The URLs listed in the <ping> should exercise the important operations in the application. For example, it should at least access the database.

AttributeMeaningDefault
urlURL to test for failurerequired
sleep-timetime to sleep between pings.15 min
retry-counthow many times to retry failures before restarting.3
retry-timehow long to sleep between failures.1 sec
class-namespecify a custom ping class (Resin 2.0.3)com.caucho.http.admin.PingThread
socket-timeouthow long the socket should wait for a response before timing out.10s

<caucho.com>
<http-server>
  <ping>
    <sleep-time>1m</sleep-time>
    <retry-count>3</retry-count>
    <retry-time>1s</retry-time>
    <url>http://localhost:8080/test.jsp</url>
  </ping>

  ...
</http-server>
</caucho.com>

Custom ping classes must extend com.caucho.http.admin.PingThread. For example, the PingMailer will mail when the PingThread fails.

PingMailer additional Attributes
AttributeMeaningDefault
mail-toRecipient of the warning mailrequired
mail-fromSender of the mailthe user of the Resin process
mail-subjectThe subject of the mail"Resin ping has failed"

<ping>
  <class-name>com.caucho.http.admin.PingMailer</class-name>
  <sleep-time>1m</sleep-time>
  <retry-count>3</retry-count>
  <retry-time>1s</retry-time>
  <url>http://localhost:8080/test.jsp</url>

  <mail-to>webmaster@localhost</mail-to>
</ping>

No default.

srun

Defines multiple client machines for load balancing. This directive used by the web server (Apache or IIS) and by the Java portion of Resin.

Each srun directive adds a new client to receive load balanced requests. With Resin 1.2, the resin.conf must have at least one <srun> or <http> element.

AttributeMeaningDefault
idsrun identifier name.none
hostThe host name of the client srun.all interfaces
portThe port name of the client srun.none
connect-timeoutHow long to wait for a connection from the web server to the Resin srun before giving up.30 sec
live-timeHow long the web-server/srun connection should stay live.10 sec
dead-timeHow long before checking that a srun has come back up.5 sec
timeoutHow long the load balancing server should wait for a response.30 sec
thread-maxMaximum number of live threads.200
thread-minMinimum number of live threads.5
thread-keepaliveNumber of keepalive threads100
request-timeoutMax time for a request, after this the request will be interrupted.30 sec
listenValue of the socket listen parameter5
accept-buffer-sizeNumber of sockets in the accept buffer.256
shutdown-wait-timeHow long to wait for connections to finish before exiting.10 sec.
Load balance over three machines
<caucho.com>
  <http-server>
    <srun id='a' host='host1.caucho.com' port='6802'>
    <srun id='b' host='host2.caucho.com' port='6802'>
    <srun id='c' host='host2.caucho.com' port='6803'>
  </http-server>
</caucho.com>

To start srun 'a' use a command line like

unix> srun.sh -server a
Resin 2.1.0
srun listening to host1.caucho.com:6802

On Unix, when starting a daemon, you'll need to specify a unique pid file.

unix> srun.sh -server a -pid a.pid start

srun-backup

Defines backup client machines for load balancing. This directive is only picked up by the load balancer. The Java portion of Resin treats a <srun-backup> like any other srun. Normally, <srun-backup> is only used when each web server has a primary <srun> in preference to other <srun> JVMs. See the load-balancing section for more information.

AttributeMeaningDefault
idsrun identifier namenone
hostThe host name of the client srunall interfaces
portThe port name of the client srunnone
connect-timeoutHow long to wait for a connection from the web server to the Resin srun before giving up.30 sec
live-timeHow long a keepalive connection will remain alive before closing.5 sec.
dead-timeHow long to treat a non-responding srun before trying again.5 sec.
shutdown-wait-timeHow long to wait for connections to finish before exiting.10 sec.

thread-keepalive

Number of threads to be used in keepalive requests. When Resin is used in combination with a web server, like Apache or IIS, Resin will reuse the socket connection to that web server if possible. thread-keepalive specifies the number of theads that can be used in these keepalive connections.

Defaults to 100.

thread-max

Maximum number of request-handling threads.

Defaults to 200.

host

access-log

Specifies the access log file. The log is relative to $RESIN_HOME. You can use the special path $app-dir to make the log relative to the host, e.g. $app-dir/WEB-INF/log/access.log.

AttributeDescriptionDefault
idThe access log path.required
formatAccess log format.see below
class-nameClass implementing AbstractAccessLog for custom logging.
rollover-periodhow often to rollover the log. Normally in days (15D), weeks (2W) or months (1M).none
rollover-sizemax size of the log before a rollover.10 meg
archive-formatformat the name of the archive file.n/a

The rollover-period variable controls how often the access log will be rotated. When the time runs out, Resin will move the old log file to a timestamped one, e.g. access.log20001114. Rollovers happen at midnight in the local time if the time period is a day or longer.

The access log formatting variables follow the Apache variables:

%bresult content length
%hremote IP addr
%{xxx}irequest header xxx
%{xxx}oresponse header xxx
%{xxx}ccookie value xxx
%nrequest attribute
%rrequest URL
%sstatus code
%{xxx}trequest date with optional time format string.
%Ttime of request in seconds
%uremote user
%Urequest URI

The default format is:

"%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""

<host id=''>

  <access-log id='log/access.log'>
    <rollover-period>2W</rollover-period>
  </access-log>

 ...

</host>

If the web-app doesn't specify an access-log, it will use the host's access-log.

doc-dir

Specifies the document directory for the <host> or <http-server>.

<doc-dir> values may use use system properties, like $server.root or $resin.home or even $foo.

<host id=''>
  <doc-dir>/opt/web/default_host</doc-dir>

 ...

</host>

Default: Defaults to <root-dir> if specified. Otherwise <host> defaults to the document directory of the <http-server> <http-server> defaults to the server-root.

root-dir

Specifies the root directory for the <host> or <http-server>. Non-document data like log files and war directories are based off the root directory.

<root-dir> values may use use system properties, like $server.root or $resin.home or even $foo.

<host id=''>
  <root-dir>/opt/web/default_host</root-dir>
  <doc-dir>doc</doc-dir>

 ...

</host>

Default: Hosts defaults to the <root-dir> of the <http-server>. <http-server> defaults to the server-root.

session-cookie

Configures session cookie. The default is "JSESSIONID".

session-url-prefix

Configures the URL prefix to be used for url-rewriting. The default is ";jsessionid=".

server-name

Defines the canonical url for the host. In some cases, the specific URL that's used for a virtual host might be different from the <host id='...'> name. <server-name> lets you specify the exact URL to be added when using a sendRedirect.

...
<host id='foo.com'>
  <server-name>http://foo.com</server-name>
  ...
</host>
...

server-listener

Specifies the classname for a listener when the server starts and shuts down. The class must be in the system classpath because it's called before the dynamic classpaths have been created and after they've been destroyed.

The server listener class must extend com.caucho.http.admin.AbstractServerListener.

<http-server>
  <server-listener>
    <class-name>test.MyListener</class-name>
  </server-listener>
  ...

servlet-classloader-hack

Enables the Servlet specification classloader hack. The Servlet 2.3 classloader order violates the JDK classloader specification. By default, therefore, Resin follows the JDK requirements. Those application which need to violate the JDK spec may enable the servlet-classloader-hack.

By default, the hack is disabled.

sticky-sessions

Enables or disables sticky-session load balancing.

The default is true to enable sticky sessions.

url-character-encoding

Defines the character encoding to be used for decoding the URL. Because the HTTP protocol does not specify the encoding to be used, the server must specify the encoding beforehand.

Default: utf-8

url-length-max

Specifies the maximum length allowed in a HTTP URL. Requests with longer lengths will receive an error.

Default: 8192

war-dir

Specifies a special directory to place war files. Any .war (web-application resource) file placed in the war directory will be automatically expanded and installed. The .war file will be expanded into war-expand-dir, if specified.

The war-dir is relative to $RESIN_HOME, not to the virtual host's app-dir.

<host id='www.foo.com'>
  <war-dir>foo-apps</war-dir>
</host>

Given the above example, if you put foo.war in resin1.2/foo-apps, Resin will automatically expand it and install it with the prefix /foo. So browsing http://localhost:8080/foo will give the top-level contents.

Generally, war files use WEB-INF/web.xml for configuration. The syntax is the same as for other application configuration.

No war-dir is defined by default.

war-expand-dir

Specifies the destination of war expansion. Any .war (web-application resource) file placed in the war-dir directory will be automatically expanded into war-expand-dir. You can also create a web-app by creating a directory in war-expand-dir.

The war-dir is relative to $RESIN_HOME, not to the virtual host's app-dir.

The special directory ROOT lets you define the root web-app.

Generally, war files use WEB-INF/web.xml for configuration. The syntax is the same as for other application configuration.

Default: Defaults to the value of <war-dir>.

web-app

Specifies an application. Applications are self-contained subtrees of the web site. They have distinct Application objects, sessions, and servlet mappings. Applications can even be deployed entirely from .jar files.

The full application configuration is described in a separate page.

Applications have a root app-dir similar to the document root. By default, it's just the same as the relative path.

Beneath the app-dir root, a special directory WEB-INF contains servlet classes and beans. WEB-INF/classes contains Java source files and Java classes. WEB-INF/lib contains additional jar files for the application.

AttributeMeaningDefault
idThe url prefix of the application.required
url-regexpA regular expression matching a url prefix.none
app-dirThe application's root directory.The subdirectory of the host's app-dir named by id

<host id='foo.com'>

<web-app id='example/tictactoe'
         app-dir='c:\work\ttt'>
  <servlet-mapping url-pattern='*.foo'
                      servlet-name='com.caucho.jsp.XtpServlet'/>
</web-app>

</host>

The url-regexp configuration allows for dynamic applications, for example, creating a new application for each user.

Per-user Servlet Directory
<host>

<web-app url-regexp='^/~([^/]+)'
         app-dir='/home/$1/public_html'>
  ...
</web-app>

</host>

In the above example, users will put their own web.xml in /home/user/public_html/WEB-INF/web.xml. Classes belong in public_html/WEB-INF/classes.

Note: Only the Resin Java process understands regexps. Because mod_caucho, isapi_srun and the other web server plugins don't understand the regexps, you may need to do additional work to make the web server send the request to Resin.

Formal Description

http-server ::= http,
                srun,
                srun-backup,
                thread-max,
                thread-min,
                thread-keepalive,
                request-timeout,
                ping,
                alternate-session-url-prefix,
                session-url-prefix,
                sticky-sessions,
                ignore-client-disconnect,
                global-system-properties,
                root-dir,
                doc-dir,
                cache,
                host*,
                default host or web-app tags*


Misc resin.conf
Configuration
Port resin.conf
Copyright © 1998-2002 Caucho Technology, Inc. All rights reserved.
Resin® is a registered trademark, and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.