| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Resin provides a set of convenient servlets in the com.caucho.servlets.* package.
Sends an HTTP error code and optionally an error message back to the client.
This servlet is particularily useful for blocking access to portions of your web-app that contain files not meant to be accessible to users. In this example, the default 404 (meaning "Not Found") is used as the error message; the user cannot even determine if the file they are trying to access exists.
Configures a front-end Resin instance to load-balance requests to backend Resin instances. Each LoadBalanceServlet instance will distribute the requests to a configured cluster. The urls that get load balanced are the ones that are mapped to the LoadBalancedServlet, using the usual servlet-mapping. LoadBalanceServlet supports sticky-sessions. If the request already has a session, the backend server matching that session will be used. Otherwise, the least busy backend server will be used as counted by number of active requests. If several backend servers are equally busy, the selection uses a round-robin to distribute the load.
The usual case balances all requests to backend servers. The front-end Resin instance has a resin.conf similar to the one shown here. It configures the front-end instance to balance the load to the backend servers. The backend Resin instances have a resin.conf file that configures the web site, similar to a conf file that is used when only one instance of Resin used for the server.
LoadBalanceServlet is also used to allow a separate JVM for a web-app or a host. The See determines the strategy to use for choosing a backend server for a request that does not have a sticky-session. The `least-connection' strategy chooses the backend server that has the least number of connections at the time the decision is made. This is a good general purpose strategy, and compensates for differences in a backend server's ability to service connections. The `round-robin' strategy does a straight round robin, choosing the backend server that follows the last backend server chosen. class com.caucho.servlets.LoadBalanceServlet .
Implements CGI calls. The url is assumed to refer to an executable file, and the operating system is instructed to execute the program or script. The usual CGI environment variables are set, and the current directory is the value of $RESIN_HOME
See class com.caucho.servlets.CGIServlet .A CGI script must output a blank line between the HTTP header(s) and the rest of the response. If no blank line is encountered, the contents of your browser page will be blank. Usually a CGI script will output a Content-Type: header and then a blank line before the content:
The directory servlet provides the basic directory browsing. Sites will normally disable it.
Implements the FastCGI protocol. FastCGI allows some CGI clients like PHP to run quicker and more efficiently.
The FastCGIServlet creates a socket connection from Resin to the backend program that supports the fastcgi protocol. <servlet-mapping> is used to configure the filename patterns of scripts that are handled by the backend program. The following example configures Resin so that any files within a single webapp matching the pattern"*.php" are handled by the backend program:
Assuming PHP has been compiled with -fastcgi enabled, you might start PHP like:
Mapping is enabled for all web-apps with the use of <web-app-default> . In this example, filenames with the pattern "*.php" and the pattern "*.phtml" are handled by the backend program:
class com.caucho.servlets.HttpProxyServlet is a servlet that proxies to another server. This can be useful for providing access to legacy backend servers.
There is a bit more power using servlet-regexp and regular expressions:
|