DSpace 6: Configure apache2 as reverse proxy in front of tomcat

Last updated on: Published by: Systems Librarian 2

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>

	ProxyRequests On
	ProxyPass / http://localhost:8080/
	ProxyPassReverse / http://localhost:8080/

	<Location "/">
	  Order allow,deny
	  Allow from all


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

Related posts

2 Replies to “DSpace 6: Configure apache2 as reverse proxy in front of tomcat”

  1. Stephano

    Thank you for your instructions on how to reverse apache2 with tomcat. In our institution, we are running DSpace 6.3 we want to implement SSL. Do you have instructions on how to do it with the apache plugin?
    Thank you.

    1. Systems Librarian Post author

      Hi @Stephano. First you need to install tomcat and run it on a port number such as 8080, which is the default port number anyway for tomcat. Then install apache2. By default it runs on port 80. Then follow the instructions on this post to turn it into a proxy. To add ssl you can follow instructions here to install the free ssl from Letsencrypt which your institution is using https://certbot.eff.org/instructions?ws=apache&os=ubuntufocal. The instructions at the link are for Ubuntu 20, but you can select your OS on that same page

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.