This article discusses how to use Apache web server as a proxy (reverse proxy) to a Tomcat server. Apache is often used as a proxy to Tomcat. This allows the server to host a website that needs a traditional site (html, php, etc) as well as some java served by Tomcat. Apache can be the front-end for all content served.
The changes required from a working Apache config is very simple. The following snippet shows the changes required:
<VirtualHost *:80> ProxyPass /sample http://localhost:8080/sample/ ProxyPassReverse /sample http://localhost:8080/sample/ ServerAdmin [email protected] DocumentRoot /var/www/html/www.agix.local ServerName www.agix.local ServerAlias agix.local ErrorLog logs/www.agix.local-error_log CustomLog logs/www.agix.local-access_log common </VirtualHost>
You can see the two “Proxy” lines at the top of the snippet. This will allow us to access the Tomcat application “sample” by visiting the URL “http://www.agix.local/sample”.