Configuring Apache to Proxy Tomcat Using the AJP Protocol.
Step 1. Configure Tomcat
Comment out the normal connector above, and uncomment the AJP connector:
Adjust the port if you wish and add in the URIEncoding="UTF-8" attribute.
Step 2. Configure Apache
Open httpd.conf and scroll to the large LoadModule section. Ensure you have the following uncommented
In my httpd.conf, right at the bottom there is a line:
Create an ajp.conf file.
You could put the configuration for AJP in the main httpd.conf file but I prefer to keep things separated.
etc/apache24/Includes/proxy-ajp.conf
*Optional
(
A sample balancer setup
Comment out the normal connector above, and uncomment the AJP connector:
Adjust the port if you wish and add in the URIEncoding="UTF-8" attribute.
<!--
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
-->
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
Step 2. Configure Apache
Open httpd.conf and scroll to the large LoadModule section. Ensure you have the following uncommented
#LoadModule proxy_module libexec/apache24/mod_proxy.so
#LoadModule proxy_ajp_module libexec/apache24/mod_proxy_ajp.so
In my httpd.conf, right at the bottom there is a line:
Include etc/apache24/Includes/*.conf
Create an ajp.conf file.
You could put the configuration for AJP in the main httpd.conf file but I prefer to keep things separated.
etc/apache24/Includes/proxy-ajp.conf
*Optional
(
ProxyRequests Off
<proxy *>
Order deny,allow
Deny from all
Allow from localhost
</Proxy>
)
ProxyPass /examples ajp://localhost:8009/examples
ProxyPassReverse /examples ajp://localhost:8009/examples
A sample balancer setup
ProxyPass "/special-area" "http://special.example.com" smax=5 max=10
ProxyPass "/" "balancer://mycluster/" stickysession=JSESSIONID|jsessionid nofailover=On
<Proxy "balancer://mycluster">
BalancerMember "ajp://1.2.3.4:8009"
BalancerMember "ajp://1.2.3.5:8009" loadfactor=20
# Less powerful server, don't send as many requests there,
BalancerMember "ajp://1.2.3.6:8009" loadfactor=5
</Proxy>
Comments
Post a Comment