Step 1: Install Apache Tomcat
The first step is to install the Apache Tomcat server. In this guide, we will use Apache Tomcat 10.
Update your system
Start by updating your system:
sudo apt upgrade
Install Java JDK
Before installing Apache Tomcat, we need to ensure we have a working Java version installed.
Use the command below to install openjdk 11.
Once the installation completes, open the terminal and check the JDK version as:
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment (build 11.0.11+9-Ubuntu-0ubuntu2.20.04)
OpenJDK 64-Bit Server VM (build 11.0.11+9-Ubuntu-0ubuntu2.20.04, mixed mode, sharing)
If you get the “command not found” error, ensure the installation was successful.
Install Apache Tomcat
The next step is to download and install Apache Tomcat. Open your terminal and enter the command:
The above command will download the tomcat 10 package.
Next, unzip the package as:
Start the Apache Tomcat service
Navigate into the extracted directory/bin:
Start the tomcat service:
Step 2: Install Apache HTTPD
The following step is to install the Apache HTTPD server. Use the apt command as:
Start the HTTPD service
Upon completion, start the httpd service:
Step 3: Enable mod_proxy module
Once we have all the servers up and running, we can now configure the reverse proxy for the tomcat server.
Start by enabling the mod_proxy module for the Apache HTTPD:
Step 4: Configure Apache Virtual Hosts
The next step is to configure virtual host routing for the httpd server. Doing this allows us to forward requests to their desired destinations.
Enter the virtual host entry as:
ProxyPass /webapps http://localhost:8080/
ProxyPassReverse /webapps http://localhost:8080/
Allow from all
Save and close the file.
Finally, restart the apache server as:
You can test the proxy by navigating to http://localhost/webapps
This guide showed you how to set up a reverse proxy for the Apache Tomcat using the Apache HTTPD server.