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. There could be other reasons, managing SSL certificates on tomcat is not as straight forward as itis on apache2 or other web servers such as nginx.
This guide assumes that you have installed DSpace and that it is running 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.
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 hostname.com ProxyRequests On ProxyPass / http://localhost:8080/ ProxyPassReverse / http://localhost:8080/ <Location "/"> Order allow,deny Allow from all </Location> </VirtualHost>
Issue the following command to restart apache2
sudo systemctl restart apache2
Now if you go to http://localhost in your browser, you should see your dspace being served by apache2