![]() | ||||||||||||||||||||||||||
resin with apache and iis
Resin provides a fast servlet runner for Apache 2.2, and IIS allowing these HTTP servers to dispatch requests to Resin.
Before integrating Resin with Apache, it is valuable to configure Resin as a standalone server, especially with more complicated setups such as those involving virtual hosts. Doing so isolates the steps and makes troubleshooting easier. Many users find that the performance, flexibility, and features of Resin make it a desirable replacement for Apache and IIS. These 3rd party HTTP servers add overhead to Resin's operation, therefore you should have a specific reason to run one of them with Resin. How Resin integrates with ApacheWhen used with Apache, Resin serves JSPs and Servlets and Apache serves
static content like html and images. Apache is a frontend server, it handles
the request from the browser. Resin's ![]() mod_caucho queries the backend server to distinguish the URLs going to Resin from the URLs handled by Apache. The backend server uses the <servlet-mapping> directives to decide which URLs to send. Also, any *.war file automatically gets all its URLs. Other URLs stay with Apache. There's a more complete discussion of the URL dispatching in the How the Plugins Dispatch to Resin page. Unix InstallationResin needs Apache 2.x or greater and DSO support. You probably have DSO
support, but if you're not sure, you can check for when
running checking apache httpd for mod_so.c unix> /usr/local/apache/bin/httpd -l Compiled-in modules: ... mod_so.c ... If you don't have DSO support, you can recompile Apache or install another package from your operating system vendor. Check their documentation for more details. Compiling mod_caucho.soCompiling on Unix is usually as easy as changing the way that you configure Resin during installation:
Windows Installation
The The httpd.conf file is also easily modified manually: httpd.conf
LoadModule caucho_module \
<resin.home>/win32/apache-2.0/mod_caucho.dll
ResinConfigServer localhost 6800
<Location /caucho-status>
SetHandler caucho-status
</Location>
Replace with above if you're using a 64-bit version of Apache. Configuring resin.xml
The communication between
The resin.xml
<resin xmlns="http://caucho.com/ns/resin"
xmlns:resin="urn:java:com.caucho.resin">
...
<cluster id="app-tier">
...
<server id="" address="127.0.0.1" port="6800"/>
...
The resin.xml and the layout of your webapps should match the layout that Apache expects. The mapping of urls to filesystem locations should be consistent between Apache and the backend Resin server. The default resin.xml looks in
resin.xml
<resin xmlns="http://caucho.com/ns/resin"
xmlns:resin="urn:java:com.caucho.resin">
...
<cluster id="">
...
<host id="">
<web-app id='/' document-directory="/usr/local/apache/htdocs"/>
</host>
...
</cluster>
</resin>
Configuring Apache httpd.conf
The
The After any change to httpd.conf, restart Apache. Now browse http://localhost/caucho-status. Manual configuration of dispatchingYou can also dispatch to Resin directly from the httpd.conf. Instead of relying on the ResinConfigServer directive to determine which url's to dispatch to the backend server, Apache handler's are used to specify the url's to dispatch. CauchoHost 127.0.0.1 6800 <Location /foo/*> SetHandler caucho-request </Location>
Requests dispatched directly from the Apache httpd.conf will not appear in /caucho-status. Load BalancingThe Load Balancing section provides an introduction to the concepts of load balancing. mod_caucho recognizes cluster configurations for load balancing. Requests are distributed to all machines in the cluster, all requests in a session will go to the same host, and if one host goes down, Resin will send the request to the next available machine. Optional backup machines only receive requests if all of the primaries are down. mod_caucho only needs to know about one of the backend servers. It will query that backend server, and learn about all of the other members of the cluster. mod_caucho keeps a local cache of the configuration information, so if the backend server becomes unavailable then the cached configuration will be used until the backend server becomes available again. The httpd.conf file can also specify more than one backend server, when mod_caucho checks for configuration updates, it will check each in turn, and only if none of them are available will it use the local cached copy. ResinConfigServer 192.168.0.11 6800 ResinConfigServer 192.168.0.12 6801 Manual configuration of load balanced dispatching
Manual dispatching in httpd.conf can also specify the backend hosts and the backend backup hosts, as an alternative to using CauchoHost 192.168.0.11 6800 CauchoBackup 192.168.0.11 6801 CauchoHost 192.168.0.12 6800 CauchoBackup 192.168.0.12 6801 <Location /foo/*> SetHandler caucho-request </Location> Troubleshooting
![]() Environment VariablesConfigure the following two environment variables in the Control Panel: JAVA_HOME=C:\jdk1.5.0 RESIN_HOME=C:\Resin Of course, adjust these to the correct directories for Java and Resin if they differ from your own. Configuring IIS/PWSTo configure Resin with IIS, you must follow the following steps:
ISAPI FilterYou should run ISAPI Filter Priorityisapi_srun.dll installs itself as the default priority. Some users may need to set the priority to a higher level, e.g. to override IIS's DAV support. resin.ini ResinConfigServer localhost 6802 CauchoStatus yes IISPriority high Configuring resin.xmlresin.xml should mirror the configuration of IIS. In other words, you need to configure the document root and any directory aliases. For many users, the only need to change needed in Resin is to change the document-directory attribute from 'webapps/ROOT' to something like 'C:/inetpub/wwwroot'. The mapping of url paths from the browser to real files on the disk must be the same for Resin as they are for IIS. For more complicated configurations that use mappings in IIS, you'll need to add path-mapping attributes to match. Example: resin.xml
<resin xmlns="http://caucho.com/ns/resin">
<cluster id="">
<!-- configures the default host, matching any host name -->
<host id="">
<!-- configures the root web-app -->
<web-app id='/'>
<root-directory>C:/inetpub/wwwroot</root-directory>
<!-- adds xsl to the search path -->
<class-loader>
<simple-loader path="$host-root/xsl"/>
</class-loader>
</web-app>
</host>
</cluster>
</cluster>
Load BalancingResin's IIS plugin supports load balancing in much the same way as mod_caucho does for Apache. Consult the mod_caucho load balancing section for more details. Manual ConfigurationExperts may want to configure Resin/IIS by hand instead of using the setup program. The steps involved are:
Copying isapi_srun.dll to directory is relatively straightforward. If you're upgrading to a new version of Resin, you may need to stop IIS (control panel/services) to get permission to overwrite isapi_srun.dll. The resin.ini is an optional file in to override the automatic registry $RESIN_HOME/conf/resin.xml configuration file. If you only have one Resin server, you should not create a resin.ini and let isapi_srun.dll use the registry value set by the setup.exe program. resin.ini is only needed if you have multiple Resin configuration files for different IIS virtual hosts. The resin.ini should contain the following line: ResinConfigServer localhost 6802 You can change the host from to a backend server. You can also add multiple items to cluster the configuration. For debugging, you can add a "CauchoStatus yes" line to the resin.ini: ResinConfigServer localhost 6802 CauchoStatus yes For security purposes, the default value of CauchoStatus is "no" when you have a resin.ini. Adding an ISAPI filter is accomplished in the IIS manager. Virtual Sites (Virtual Hosts)If IIS is managing multiple virtual sites (better known as virtual hosts), then you need to configure IIS to use the isapi_srun.dll filter for each virtual site. Configure IIS to have the virtual directory for each virtual site point to , so that each virtual site uses the isapiu_srun.dll. Troubleshooting
Troubleshooting IIS 6IIS 6/Windows 2003 users may need to perform additional steps.
The previous sections show how to configure Apache and IIS to work with Resin. This section shows how the plugins for these servers interpret the Resin's configuration and how to change that configuration for your deployment. The web server plugins (mod_caucho and isapi_srun) have two main tasks:
ResinConfigServermod_caucho discovers its configuration by contacting the ResinConfigServer specified in the httpd.conf or resin.ini. The ResinConfigServer can be any Resin server. When a user requests a URL, mod_caucho uses the configuration it has determined from the ResinConfigServer to determine whether Resin or Apache should handle the request. That decision is based on the configuration in the ResinConfigServer's resin.xml. servlet-mapping selects URLsThe servlet-mapping tag selects the URLs to send to Resin. <host> and <web-app> group the servlet-mapping tags. url-patternservlet-mapping's url-pattern selects the URLs to pass to Resin. servlet-mapping and url-pattern are part of the Servlet 2.3 standard, so there are many references explaining how it works. url-pattern can take one of four forms:
url-regexpNote mod_caucho does not understand regular expressions. If you put regular expressions in your resin.xml, mod_caucho will not send the request to Resin. Apache will handle the request itself.If you want to use regular expressions in servlet-mapping, web-app, or hosts, you must use Apache-specific configuration to send the request to Resin. You can see this by looking at /caucho-status. /caucho-status will not display any regular expressions. special servlet-mappingsThere are two special servlet-names which only affect the plugins: and . will direct a request to Resin. The servlet engine itself will ignore the plugin_match directive. You can use plugin_match to direct an entire subtree to Resin, e.g. to workaround the regexp limitation, but allow Resin's other servlet-mapping directives to control which servlets are used. keeps the request at on the web server. So you could create a directory where all documents, including JSPs are served by the web server.
<!-- send everything under /resin to Resin -->
<servlet-mapping url-pattern='/resin/*'
servlet-name='plugin_match'/>
<!-- keep everything under /static at the web server -->
<servlet-mapping url-pattern='/static/*'
servlet-name='plugin_ignore'/>
<web-app>web-apps collect servlets and JSP files into separate applications. All the servlet-mappings in a web-app apply only to the URL suffix. In the following example, every URL starting with /prefix/url maps to the web-app. The servlet-mapping only applies to URLs matching the prefix. ... <web-app id='/prefix/url'> <servlet-mapping url-pattern='*.foo' .../> </web-app> .. In the exaple, mod_caucho will match any URL matching /prefix/url/*.foo. /prefix/url/bar.foo will match, but /test/bar.foo will not match. Note Resin standalone allows a attribute instead of an id. Because mod_caucho does not understand regexps, it will ignore any web-app with a attribute.Note web.xml files and war files are treated exactly the same as web-apps in the resin.xml. <host>host blocks configure virtual hosts. There's a bit of extra work for virtual hosts that we'll ignore here. (Basically, you need to add Apache directives so Resin knows the name of the virtual host.) For dispatching, a host block gathers a set of web-apps. Each host will match a different set of URLs, depending on the web-app configuration. The default host matches any host not matched by a specific rule. As usual, /caucho-status will show the URLs matched for each host. Note mod_caucho does not understand the host attribute. It will ignore all hosts using . To get around this, you can either configure Apache directly (see below), or configure the default host with the same set of servlet-mappings. Since mod_caucho will use the default host if no others match, it will send the right requests to Resin.
| ||||||||||||||||||||||||||