All Linux HowTo's

Apache proxy to Tomcat on CentOS/Redhat

Share This:

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 support@agix.local
    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”.

Similar Posts:

Leave a Reply

Your email address will not be published. Required fields are marked *