At this point, restarting Apache should enable mod_proxy and mod_proxy_ajp when loading. We now need to configure the web application handling mechanism. First, determine if Apache will be serving images and HTML, but tomcat serves JSP files all from inside of the same directory. If this is not the case, configuration is easily done by changing the
JkMount /webapplication/* ajp13
configuration line to
ProxyPass /webapplication/ ajp://localhost:8009/webapplication/
And restart apache. If a single directory contains both HTML and JSP files, the ProxyPass directive will not handle the *.jsp mechanism. Instead, the rewrite module (step 7 in enabling the appropriate modules) is required, and a special RewriteRule directive is used. The syntax for the RewriteRule directive :
RewriteRule REQUEST_URI TARGET [FLAGS]
For example :
JkMount /gw/*.jsp ajp13
Would be rewritten as :
RewriteRule ^/gw(.*\.jsp)$ ajp://localhost:8009/gw/$1 [P]
This rule simply enables the proxy module using RewriteRule for anything that matches the parameter (the [P] flag). The example above will send anything hit with /gw/*.jsp and forward it to tomcat using the ajp protocol on port 8009 for the localhost.
Once the configuration is set up, restart Apache, and it should now be communicating with Tomcat.
Partager