<host>: Virtual Host configuration
Resin 3.1

Documentation
Examples
Changes

Overview
Installation
Configuration
Quercus
SOA/IoC
JSP
Servlets and Filters
Admin (JMX)
EJB
Amber
Security
Performance
Hessian
XML and XSLT
Third-party
Troubleshooting/FAQ

tags
Common Tasks
Relax Schema
howto
Config FAQ
Scrapbook
DB Scrapbook

env tags
<resin>
<cluster>
<server>
port tags
<host>
<web-app>
<database>
session tags
rewrite tags
service tags
log
el variables
el control
port tags
tags
<web-app>

Describes the virtual host configuration tags.

See Also

  • See the index for a list of all the tags.
  • See Web Application configuration for web.xml (Servlet) configuration.
  • See Environment configuration for resources: classloader, databases, connectors, and resources.
  • See Log configuration for access log configuration, java.util.logging, and stdout/stderr logging.
<access-log>
child of cluster, host, web-app

<access-log> configures the access log file.

As a child of web-app, overrides the definition in the host that the web-app is deployed in. As a child of host, overrides the definition in the server that the host is in.

pathOutput path for the log entries, see "Log Paths".required
formatAccess log format.see below
rollover-periodhow often to rollover the log. Specify in days (15D), weeks (2W), months (1M), or hours (1h). See Rollovers. none
rollover-sizemaximum size of the file before a rollover occurs, in bytes (50000), kb (128kb), or megabytes (10mb). See Rollovers. 1mb
archive-formatthe format for the archive filename when a rollover occurs, see Rollovers. see below
resin:typea class extending com.caucho.server.log.AccessLog for custom logging com.caucho.server.log.AccessLog
initbean-style initialization for the custom classn/a

The default archive format is

path + ".%Y%m%d" or
  path + ".%Y%m%d.%H" if rollover-period < 1 day.
<access-log> in host configuration
<resin xmlns="http://caucho.com/ns/resin">
<cluster id="app-tier">

  <host id="">
    <access-log path='log/access.log'>
      <rollover-period>2W</rollover-period>
    </access-log>
  </host>
</cluster>
</resin>

The access log formatting variables follow the Apache variables:

%bresult content length
%Dtime taken to complete the request in microseconds (since 3.0.16)
%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 taken to complete the request in seconds
%uremote user
%Urequest URI

The default format is:

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

resin:type allows for custom logging. Applications can extend a custom class from com.caucho.http.log.AccessLog. Bean-style initialization can be used to set bean parameters in the custom class.

<resin xmlns="http://caucho.com/ns/resin">
<cluster id="app-tier">

  <host id='foo.com'>
    <access-log resin:type='test.MyLog'>
               path='${server.root}/foo/error.log'
               rollover-period='1W'>
      <init>
        <foo>bar</foo>
      </init>
    </access-log>
    ...
  </host>

</cluster>
</resin>
Environment
child of resin, cluster, host, web-app

All Environment tags are available to the <cluster>. For example, resources like <database>.

host environment
<resin xmlns="http://caucho.com/ns/resin">
  <cluster id="app-tier">
     <server id="a" .../>

     <host id="www.foo.com">
        <database jndi-name="jdbc/test">
            <driver type="org.postgresql.Driver">
                <url>jdbc:postgresql://localhost/test</url>
                <user>caucho</user>
            </driver>
        </database>

        <web-app-default path="webapps"/>
    </host>
  </cluster>
</resin>
<error-page>
child of cluster, host, webapp

<error-page> defines a web page to be displayed when an error occurs outside of a web-app. Note, this is not a default error-page, i.e. if an error occurs inside of a <web-app>, the error-page for that web-app will be used instead.

See webapp: error-page.

<host>
child of cluster

<host> configures a virtual host. Virtual hosts must be configured explicitly.

idprimary host namenone
regexpRegular expression based host matchingnone
host-nameCanonical host namenone
host-aliasAliases matching the same hostnone
secure-host-nameHost to use for a redirect to SSLnone
root-directoryRoot directory for host filesparent directory
startup-mode'automatic', 'lazy', or 'manual', see Startup and Redeploy Modeautomatic
explicit host
<host host-name="www.foo.com">
  <host-alias>foo.com</host-alias>
  <host-alias>web.foo.com</host-alias>

  <root-directory>/opt/www/www.foo.com</root-directory>

  <web-app id="/" document-directory="webapps/ROOT">
    
  </web-app>
  ...
</host>
regexp host
<host regexp="([^.]+)\.foo\.com">
  <host-name>${host.regexp[1]}.foo.com</host-name>

  <root-directory>/var/www/hosts/www.${host.regexp[1]}.com</root-directory>

  ...
</host>

It is recommended that any <host> using a regexp include a <host-name> to set the canonical name for the host.

<host-default>
child of cluster

<host-default> configures defaults for a virtual host.

The host-default can contain any of the host configuration tags. It will be used as defaults for any virtual host.

<host-deploy>
child of cluster

<host-deploy> configures an automatic deployment directory for virtual host.

The host-deploy will add an EL variable \${name}, referring to the name of the host jar file.

pathpath to the deploy directoryrequired
expand-pathpath to the expansion directorypath
host-defaultdefaults for the expanded host
host-namethe host name to match

The following example configures /var/www/hosts as a host deployment directory. Each virtual host will have a webapps directory for .war deployment. So the directory /var/www/hosts/www.foo.com/webapps/bar/test.jsp would serve the URL http://www.foo.com/bar/test.jsp.

<host-deploy>
<resin xmlns="http://caucho.com/ns/resin">
  <cluster id="app-tier">
    <root-directory>/var/www</root-directory>

    <host-deploy path="hosts">
      <host-default>
        <web-app-deploy path="webapps"/>
      </host-default>
    </host-deploy>
  </cluster>
</resin>
<rewrite-dispatch>
child of cluster, host, web-app

<rewrite-dispatch> defines a set of rewriting rules for dispatching and forwarding URLs. Applications can use these rules to redirect old URLs to their new replacements.

See rewrite-dispatch for more details.

rewrite-dispatch
<resin xmlns="http://caucho.com/ns/resin">
  <cluster id="app-tier">

    <host host-name="www.foo.com">
      <rewrite-dispatch>
        <redirect regexp="^/foo" target="/index.php?foo="/>
      </rewrite-dispatch>
    </host>

  </cluster>
</resin>
<web-app>
child of host, web-app

<web-app> configures a web application.

idThe url prefix selecting this application.n/a
url-regexpA regexp to select this application.n/a
document-directoryThe document directory for the application, corresponding to a url of /id/. A relative path is relative to the root-directory of the containing host. Can use regexp replacement variables.A relative path constricted with the id or the regexp match
startup-mode`automatic', `lazy', or `manual', see Startup and Redeploy Modeautomatic
redeploy-mode`automatic' or `manual', see Startup and Redeploy Modeautomatic

When specified by id, the application will be initialized on server start. When specified by url-regexp, the application will be initialized at the first request. This means that load-on-startup servlets may start later than expected for url-regexp applications.

The following example creates a web-app for /apache using the Apache htdocs directory to serve pages.

<resin xmlns="http://caucho.com/ns/resin">
<cluster id="app-tier">

<host id=''>
  <web-app id='/apache' document-directory='/usr/local/apache/htdocs'>

  ...

</host>

</cluster>
</resin>

The following example sets the root web-app to the IIS root directory.

  <web-app id='/' document-directory='C:/inetpub/wwwroot'>

When the web-app is specified with a url-regexp, document-directory can use replacement variables ($2).

In the following, each user gets his or her own independent application using ~user.

<resin xmlns="http://caucho.com/ns/resin">
<cluster id="app-tier">

  <host id=''>

    <web-app url-regexp='/~([^/]*)'
             root-directory='/home/$1/public_html'>

    ...

    </web-app>

</host>

</cluster>
</resin>
<web-app-default>
child of cluster, host, web-app

<web-app-default> configures common values for all web applications.

<web-app-deploy>
child of host, web-app

<web-app-deploy> specifies war expansion.

web-app-deploy can be used in web-apps to define a subdirectory for war expansion. The tutorials in the documentation use web-app-deploy to allow servlet/tutorial/helloworld to be an independent war file.

pathThe path to the webapps directoryrequired
url-prefixurl-prefix added to all expanded webapps""
expand-pathdirectory where wars should be expandedvalue of path
lazy-inittrue if web-apps should only be initialized when first usedfalse
web-app-defaultdefaults to be applied to expaned web-apps
web-appoverriding configuration for specific web-apps

The web-app-deploy can override configuration for an expanded war with a matching <web-app> inside the <web-app-deploy>. The <document-directory> is used to match web-apps.

overriding web.xml
<resin xmlns="http://caucho.com/ns/resin">
<cluster id="app-tier">

<host host-name="www.foo.com">
  <web-app-deploy path="webapps">
    <web-app context-path="/wiki"
                document-directory="wiki">
      <context-param database="jdbc/wiki">
    </web-app>
  </web-app-deploy>
</host>

</cluster>
</resin>

port tags
tags
<web-app>
Copyright © 1998-2006 Caucho Technology, Inc. All rights reserved.
Resin ® is a registered trademark, and Quercustm, Ambertm, and Hessiantm are trademarks of Caucho Technology.