This post guides you on how to configure apache2 to run as a reverse proxy in front of tomcat. The reason I personally use apache2 instead of directly exposing tomcat is because it becomes easy to install SSL certicates and automate their renewal. This is also best practice as it is not recommended to expose your tomcat servlet to the world.
This guide assumes that you have installed DSpace 6, or any other application that you wish to run behind a proxy. It also assumes that it is configured to run on port 8080 which is the default port number for a tomcat installation.
Begin with installing apache2 on your Ubuntu 18.04 as shown below
sudo apt install apache2 -y
Now when you access http://localhost on your server, you should see the default apache2 web page.
Enable mod_proxy
Issue the following command to enable mod_proxy in apache2
sudo a2enmod proxy_http
This will enable both mod proxy and mod proxy_http at once
Configure apache2 virtual hosts
Open the file /etc/apache2/sites-enabled/000-default.conf as shown below
sudo nano /etc/apache2/sites-enabled/000-default.conf
Then edit the virtual host as shown here
<VirtualHost *:80>
ServerName YOUR-SERVER-NAME.COM
ProxyRequests On
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
<Location "/">
Order allow,deny
Allow from all
</Location>
</VirtualHost>
Restart apache2
Issue the following command to restart apache2
sudo systemctl restart apache2
Now if you go to http://YOUR-SERNAME.COM in your browser, you should see your dspace 6 application being served by apache2



Leave a Reply to Systems Librarian Cancel reply