Application Servers Information - Apache Tomcat - How to use Apache as reverse proxy with several Tomcat nodes

Purpose

This page explains the method to use Apache as reverse proxy with several Tomcat nodes

Details

1 - Install Apache httpd server and as many Tomcat nodes you need

The default apache https server installer is available here: http://httpd.apache.org/download.cgiThe apache httpd installation directory will be referred as “%APACHE_HOME%”

In order to install several tomcat instances, please, report to Application Servers Information - Apache Tomcat - How to deploy several tomcat instances.

Once the nodes are installed, add the following settings into the Tomcat settings file “%CATALINA_HOME%\N01\conf\server.xml”.

<Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true">
...

 <Valve className="org.apache.catalina.valves.RemoteIpValve"
 remoteIpHeader="x-forwarded-for"
 remoteIpProxiesHeader="x-forwarded-by"
 protocolHeader="x-forwarded-proto"/>

...
</Host>

2 - Modify default configuration in %APACHE_HOME%\conf\httpd.conf file

✅ Check the Apache modules “proxy_module” and “proxy_module_http” are loaded by Apache with the following directives. Otherwise, add them like :

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

✅ Configure the proxy module

ProxyRequests Off      # use apache as reverse proxy
ProxyVia On
ProxyTimeout 600

✅ Define the redirected links. For instance, if you want to redirect the SMART url, use these directives :

ProxyPass /SMART http://localhost:10080/SMART
ProxyPassReverse /SMART http://localhost:10080/SMART

Notes / Comments

Related Pages