caucho
Resin
FAQ
Reference Guide
JavaDoc
Demo
Tutorial

Getting Started
Configuration
EJB
Topics
JSP
XTP/XSL

Basic Config
Resin Config
HTTP Config
App Config
Servlet Config
SSL
Login Config
Taglib Config
Summary
 

Resin Config
Configuration
App Config

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>

The following "shortcut" may disappear in a future version of Resin. It's described for backward compatibility.

Simple configurations can omit the host and web-app tags. If you omit the host and web-app, the configuration belongs to the default host and default application. A simple configuration can ignore host and web-app and just put all the web-app configuration in the http-server element.
Simple Configuration
<caucho.com>
<http-server app-dir='/usr/local/web'>
  <servlet-mapping .../>
  ...
</http-server>
</caucho.com>

Index
access-log
cache
error-log
error-page
host
http
http-server
ping
request-timeout
srun
srun-backup
thread-keepalive
thread-max
war-dir
war-expand-dir
web-app

http-server

Configuration for both HTTP and srun. The configuration for both is identical, so running httpd and srun will serve exactly the same pages.

TagMeaningDefault
httpConfiguration for a HTTP portnone
srunConfiguration for load balancing (used by Apache/IIS plugin)none
srun-backupConfiguration for backup servers (used by Apache/IIS plugin)none
srun-indexSession index for this server for load balancing and distributed sessions (Resin 1.2.3)The position in the srun list.
error-pageError page for the Apache/IIS plugin to display when it can't connect to srun.none
caucho-statusEnable the /caucho-status special URL.false
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
cacheCreate a server cache to improve performancenone
hostVirtual host configuration"default" host
web-appServlet configuration"default web-app

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-typeType of the key store (default jks)
key-store-fileFile containing the certificates
key-store-passwordPassword to read the certificates
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
Basic HTTP configuration
<caucho.com>
  <http-server>
    <http port='8080'>
    ...
  </http-server>
</caucho.com>
SSL 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>

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.5 sec
dead-timeHow long before checking that a srun has come back up.5 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
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 1.2.b2
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 web server (Apache). The Java portion of Resin ignores it.

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.

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>

By default, the plugin returns "Can't connect to servlet runner."

thread-max

Maximum number of request-handling threads.

Defaults to 200.

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.

request-timeout

Time in seconds for a connection to timeout.

Defaults to 30 sec.

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

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.

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.

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

<caucho.com>
<http-server>

<host id='www.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.

By default, match any host.

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>

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

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
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.1 meg

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
%rrequest URI
%sstatus code
%trequest time
%uremote user

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.

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

<caucho.com>
<http-server>
  <ping>
    <sleep-time>1m</sleep-time>
    <retry-count>3</retry-count>
    <retry-time>1s</retry-time>
  </ping>

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

No default.

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.

war-dir

Specifies a special .war 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.

Defaults to war-dir is defined by default.


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