resin的 HTTP 和 Host 的配置-en

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:

                                

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
                  ...                  ...              ...    ...
access-log Specifies the access log file
alternate-session-url-prefix Configures an alternate URL prefix to be used for /~J=xxx/test
cache Activates the memory cache with a specified size
doc-dir Specifies the document directory for the or
error-log Specifies the file for error logging
error-page The url to display if the web server can't connect to Resin
forbid-host Selects a list of IPs that are forbidden
global-system-properties Determines if system-properties are classloader specific or global
host Defines a virtual host
http Defines a HTTP or SSL port for the standalone server
http-server Configuration for the servlet engine
ignore-client-disconnect Ignores ClientDisconnectionExceptions thrown when the browser disconnects
ping Specifies a list of URLs to test to check the webserver's uptime
root-dir Specifies the root directory for the or
server-listener Specifies the classname for a listener when the server starts and shuts down
server-name Defines the canonical url for the host
servlet-classloader-hack Enables the Servlet specification classloader hack
session-cookie Configures session cookie
session-url-prefix Configures the URL prefix to be used for url-rewriting
srun Defines multiple client machines for load balancing
srun-backup Defines backup client machines for load balancing
sticky-sessions Enables or disables sticky-session load balancing
thread-keepalive Number of threads to be used in keepalive requests
thread-max Maximum number of request-handling threads
url-character-encoding Defines the character encoding to be used for decoding the URL
url-length-max Specifies the maximum length allowed in a HTTP URL
war-dir Specifies a special directory to place war files
war-expand-dir Specifies the destination of war expansion
web-app Specifies an application

http-server

http-server

Configuration for the servlet engine.

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

Default application tags like may appear in the section. These tags will be defaults for the contained and .

alternate-session-url-prefix

Resin 2.0.5

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.

...  /~J=  ...

cache

Resin 1.1

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.

Attribute Meaning Default
dir File directory to store the cached pages resin1.2/cache
entries Number of entries allowed in the memory cache 16386
size Size in kilobytes of the memory 1024
enable true or false to disable true

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.

 ...

error-log attributes
Attribute Meaning Default
encoding character encoding The JVM's default
href The log's filename required
rollover-period How often the log should be rotated never
rollover-size How large the log can be before rotating infinite
timestamp Format for a timestamp before each entry none

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.

        

forbid-host

Resin 2.0.3

Selects a list of IPs that are forbidden.

  192.168.0.1  192.168.0.2  ...

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

Resin 1.2.3

Ignores ClientDisconnectionExceptions thrown when the browser disconnects.

      false    ...  

False by default, throws exceptions on disconnects.

global-system-properties

Resin 2.0.5

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.

...  true  ...

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.

Attribute Meaning Default
id The host name required
regexp A regular expression matching hosts. none
app-dir The root directory of the host (can use replacement vars) use http-server app-dir

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

Default application tags like may appear in the section. These tags will be defaults for the contained and .

           ...

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 will be used as the default configuration for any virtual host that doesn't match a specific block.

http

Resin 1.2

Defines a HTTP or SSL port for the standalone server.

Attribute Meaning
id http identifier name
host The listening host
port The listening port
virtual-host Virtual host to select a host block.
ssl enable ssl
key-store-type JSSE Type of the key store (default jks)
key-store-file JSSE File containing the certificates
key-store-password JSSE Password to read the certificates
key-manager-factory JSSE key manager factory type
ssl-context JSSE ssl context type
certificate-file OpenSSL certificate (Resin 2.0.5)
certificate-key-file OpenSSL key certificate (Resin 2.0.5)
certificate-key-password OpenSSL key password (Resin 2.1.1)
crypto-device OpenSSL engine (Resin 2.0.5)
thread-max Maximum number of live threads. 200
thread-min Minimum number of live threads. 5
thread-keepalive Number of keepalive threads 100
request-timeout Max time for a request, after this the request will be interrupted. 30 sec
listen Value of the socket listen parameter 5
accept-buffer-size Number of sockets in the accept buffer. 256
shutdown-wait-time How long to wait for connections to finish before exiting. 10 sec.

Basic HTTP configuration
          ...  

JSSE configuration
            true      pkcs12      keys/server.p12      changeit        ...  

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 should exercise the important operations in the application. For example, it should at least access the database.

Attribute Meaning Default
url URL to test for failure required
sleep-time time to sleep between pings. 15 min
retry-count how many times to retry failures before restarting. 3
retry-time how long to sleep between failures. 1 sec
class-name specify a custom ping class (Resin 2.0.3) com.caucho.http.admin.PingThread
socket-timeout how long the socket should wait for a response before timing out. 10s

      1m    3    1s    http://localhost:8080/test.jsp    ...

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

PingMailer additional Attributes
Attribute Meaning Default
mail-to Recipient of the warning mail required
mail-from Sender of the mail the user of the Resin process
mail-subject The subject of the mail "Resin ping has failed"

  com.caucho.http.admin.PingMailer  1m  3  1s  http://localhost:8080/test.jsp  webmaster@localhost

No default.

srun

Resin 1.1

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 or element.

Attribute Meaning Default
id srun identifier name. none
host The host name of the client srun. all interfaces
port The port name of the client srun. none
connect-timeout How long to wait for a connection from the web server to the Resin srun before giving up. 30 sec
live-time How long the web-server/srun connection should stay live. 10 sec
dead-time How long before checking that a srun has come back up. 5 sec
timeout How long the load balancing server should wait for a response. 30 sec
thread-max Maximum number of live threads. 200
thread-min Minimum number of live threads. 5
thread-keepalive Number of keepalive threads 100
request-timeout Max time for a request, after this the request will be interrupted. 30 sec
listen Value of the socket listen parameter 5
accept-buffer-size Number of sockets in the accept buffer. 256
shutdown-wait-time How long to wait for connections to finish before exiting. 10 sec.

Load balance over three machines
                

To start srun 'a' use a command line like

unix> srun.sh -server aResin 2.1.0srun 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

Resin 1.1

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

Attribute Meaning Default
id srun identifier name none
host The host name of the client srun all interfaces
port The port name of the client srun none
connect-timeout How long to wait for a connection from the web server to the Resin srun before giving up. 30 sec
live-time How long a keepalive connection will remain alive before closing. 5 sec.
dead-time How long to treat a non-responding srun before trying again. 5 sec.
shutdown-wait-time How 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.

Attribute Description Default
id The access log path. required
format Access log format. see below
class-name Class implementing AbstractAccessLog for custom logging.
rollover-period how often to rollover the log. Normally in days (15D), weeks (2W) or months (1M). none
rollover-size max size of the log before a rollover. 10 meg
archive-format format 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:

%b result content length
%h remote IP addr
%{xxx}i request header xxx
%{xxx}o response header xxx
%{xxx}c cookie value xxx
%n request attribute
%r request URL
%s status code
%{xxx}t request date with optional time format string.
%T time of request in seconds
%u remote user
%U request URI

The default format is:

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

      2W   ...

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

doc-dir

Resin 2.1

Specifies the document directory for the or .

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

  /opt/web/default_host ...

Default: Defaults to if specified. Otherwise defaults to the document directory of the defaults to the server-root.

root-dir

Resin 2.1

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

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

  /opt/web/default_host  doc ...

Default: Hosts defaults to the of the . defaults to the server-root.

session-cookie

Resin 2.1.2

Configures session cookie. The default is "JSESSIONID".

session-url-prefix

Resin 2.0

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

server-name

Resin 2.0.4

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 name. lets you specify the exact URL to be added when using a sendRedirect.

...  http://foo.com  ......

server-listener

Resin 2.0.3

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.

      test.MyListener    ...

servlet-classloader-hack

Resin 2.0.3

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

Resin 2.0

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.

  foo-apps

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

Resin 1.2.3

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 .

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.

Attribute Meaning Default
id The url prefix of the application. required
url-regexp A regular expression matching a url prefix. none
app-dir The application's root directory. The subdirectory of the host's app-dir named by id

  

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

Per-user Servlet Directory
  ...

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.

 

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1555396

 

你可能感兴趣的:(classloader,application,server,servlet,encoding,url)