So you have a VPS and you want to host tomcat application and your apache application together in it. Sure you can run them on different ports, but if you want to run jsp app also on port 80, you can use apache’s mod proxy to do so. Follow the following steps to run jsp application with apache using mod proxy.
Edit your apache conf file for your website by the following command
$sudo vim /etc/apache2/sites-available/servername.com.conf
Add/Edit the file and add the following mod below server name
ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://servername.com:8080/ ProxyPassReverse / http://servername.com:8080/
Now your config should look something like this
<VirtualHost *:80> SuexecUserGroup apache apache ServerName servername.com ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://servername.com:8080/ ProxyPassReverse / http://servername.com:8080/ Options -Indexes +IncludesNOEXEC +SymLinksIfOwnerMatch +ExecCGI allow from all AllowOverride All Options=ExecCGI,Includes,IncludesNOEXEC,Indexes,MultiViews,SymLinksIfOwnerMatch Require all granted </VirtualHost>
Quit the editor and restart apache using the following
$sudo service apache2 restart
Note on: SuexecUserGroup add www-data www-data for ubuntu, and apache apache for cent os
Now you can find the tomcat/jsp app running on port 80. This will also work with other scripts such as python/djangom nodejs. If you have any questions/feedback feel free to leave a comment.