There was a problem loading the comments.

User Guide - Using ModJK2 (old Apache/Tomcat connector)

Support Portal  »  Knowledgebase  »  Viewing Article

  Print
Applicable Plans: Standard Plus VPS, Standard Max VPS, all Advanced VPS, all Premier VPS plans running Fedora Core operating system only

Important Notice:

MODJK2 has been replaced by mod_jk. Both connectors do the same thing but mod_jk has a simpler syntax for the directives. Mod_jk is reportedly more efficient, but for most sites there will be no discernable difference. Please make sure that you are using the proper syntax. If you are using mod_jk (new approach), please refer to our Tomcat User Guide at http://support.eapps.com/hsp/tomcat. The purpose of this User Guide is to explain the syntax for ModJK2 (old approach).


Using ModJK2 to Forward Content to Tomcat (old approach)

Note: You must have the application ModJK2 installed in your VPS to use this feature. Please make sure that ModJK2, and not mod_jk is installed.

A common request is that customers want to run Tomcat on port 80, to avoid having to type in the :8080 in the URL. While this is possible, to do so would require that Tomcat runs as the user 'root', resulting in a security risk. Also, many applications such as AWStats, Web Mail, Resource Usage Utility, and others require Apache to run.

To work around this problem, we use ModJK2. This is a module for Apache which acts as a connector between Apache and Tomcat. It allows Apache to forward requests to Tomcat. Using a connector is the preferred way to use Tomcat, and is supported by eApps. If you want to run Tomcat without Apache, please refer to our Tomcat User Guide. If you do not use the approaches as explained in the Tomcat User Guide, you may incur service charges if our assistance is needed.

The ModJK2 module can be installed via the System tab of your Control Panel. The default configuration forwards any requests for .jsp files, .do files and the /servlet/ directory to Tomcat. Tomcat then looks at the appropriate host in server.xml and tries to serve the content.

1.0 Configuring ModJK2 (JkMount directives)

For each of your web sites, you can forward content to Tomcat from the Apache Web Server using the JkMount directive. Use your Control Panel to define the entry for a specific web site. These entries will automatically update the httpd.conf file safely, since it is not advisable to update httpd.conf directly. If you have a reason to update httpd.conf directly, please contact eApps Support. The instructions to create a JKMount directive are as follows:
Log into your control panel
Click on the Site tab of the desired website and then click Website Settings



Click the Custom Settings tab


Click Edit
Add in the appropriate JkMount directive for your webapp. (Note: change /mywebapp to your /webapp name, i.e the directory where your web app resides).

Click Update to save your work.
Click the General Settings tab




Click Restart. Your content will now be forwarded from Apache to Tomcat for this web site.

2.0 Configuring ModJK2 for Multiple Sites

To set up a directive for multiple sites you need to perform the instructions in section 1.0 above for each web site (domain) in your system. Each web site has its own Website Settings.

3.0 Preconfigured Directives

The following directives are added by default to customers sites that 
are created in in the Control Panel. These directives are preset and should not
be modified as they are the basic filetypes and URLs which the Tomcat
or JBoss engine should serve.

##### ModJK2 Configuration #####
##### Wildcard Mappings #####

<LocationMatch "/*\.jsp$">
JkUriSet worker ajp13:localhost:8009
</LocationMatch>
<LocationMatch "/*\.do$">
JkUriSet worker ajp13:localhost:8009
</LocationMatch>
<LocationMatch "/servlet/*">
JkUriSet worker ajp13:localhost:8009
</LocationMatch>
<LocationMatch "/RELEASE-NOTES\.txt$">
JkUriSet worker ajp13:localhost:8009

</LocationMatch>
<LocationMatch "/jakarta-banner\.gif$">
JkUriSet worker ajp13:localhost:8009
</LocationMatch>
<LocationMatch "/tomcat\.gif$">
JkUriSet worker ajp13:localhost:8009
</LocationMatch>
<LocationMatch "/tomcat-power\.gif$">
JkUriSet worker ajp13:localhost:8009
</LocationMatch>
<LocationMatch "/web-console">
JkUriSet worker ajp13:localhost:8009
</LocationMatch>
### End Wildcard Mappings ###
##### Context Mappings #####
<Location /admin>
JkUriSet worker ajp13:localhost:8009
</Location>
<Location /balancer>
JkUriSet worker ajp13:localhost:8009
</Location>
<Location /invoker>
JkUriSet worker ajp13:localhost:8009
</Location>
<Location /jbossmq-httpil>
JkUriSet worker ajp13:localhost:8009
</Location>

<Location /jmx-console>
JkUriSet worker ajp13:localhost:8009
</Location>
<Location /jsp-examples>
JkUriSet worker ajp13:localhost:8009
</Location>
<Location /manager>
JkUriSet worker ajp13:localhost:8009
</Location>
<Location /servlet-examples>
JkUriSet worker ajp13:localhost:8009
</Location>
<Location /tomcat-docs>
JkUriSet worker ajp13:localhost:8009
</Location>
<Location /web-console>
JkUriSet worker ajp13:localhost:8009
</Location>
<Location /webdav>
JkUriSet worker ajp13:localhost:8009
</Location>
### End Context Mappings ###
### End ModJK2 Configuration ###

Any http request matching these URLs will automatically
forward to Tomcat or JBoss if you have the ModJK2 package 
installed in you VE.
Note: You also need to add the following to support session IDs when cookies are not enabled: 
JkUriSet worker ajp13:localhost:8009

 

2.0 Configuring mod_jk for Multiple Sites

You can define more than one JKMount to have multiple contexts served by Tomcat. Each web site has its own Website Settings area in the control panel. Please make sure that you enter the directives in the correct place for each site. See the following example:

Share via
Did you find this article useful?  

Related Articles


On-Premise Help Desk Software by SupportPal

Categories

© Cloudscale365