How can I setup Apache2 to access my Spring REST API hosted on Tomcat 8? Is this okay? It doesn't seem to be working.
I was following this tutorial https://medium.com/@mirela95/apache-http-server-as-reverse-proxy-with-java-back-end-application-running-on-tomcat-9c8c9210783e
Here is my configuration file. It is stored under sites-available
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass /springrest http://127.0.0.1:8932/
ProxyPassReverse /springrest http://127.0.0.1:8932/
</VirtualHost>
If that is your entire config file then you don't have enough. You must have the ServerName
parameter to have things work correctly. You'll need to use:
<VirtualHost *:80>
ServerName www.example.com
ServerAlias example.com
ProxyPreserveHost on
ProxyPass /springrest http://localhost:8932/
ProxyPassReverse /springrest http://127.0.0.1:8932/
ProxyTimeout 360
</VirtualHost>
This file is normally named something like www.example.com.conf
. Once you put it into sites-available
you'll need to run sudo a2ensite www.example.com
and then sudo systemctl restart apache2
.