I have a domain that is hosted on an unmanaged VPS server with Ubuntu 16.04 I have configured my Java EE Tomcat web app to be served up at my domain name. But the response times for the app are way too slow, progressively going toward timeouts in the browser. If I stop the apache2 service and access my web app through domain:8080 the web app performance is perfect. How do you correctly configure apache2 to serve up the tomcat web app at the domain name with good performance? I realize that the easy solution is to link all references to my web app to domain:8080, but I would like to know how to correctly configure apache2 to serve up the Tomcat web app at the domain with the same performance as using domain:8080. Thanks in advance for any help.
This is my apache2 sites-available file for the domain:
<VirtualHost *:80>
# Admin email, Server Name (domain name) and any aliases
ServerAdmin webmaster@lae-laeweb.com
ServerName lae-laeweb.com
ServerAlias www.lae-laeweb.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html
DocumentRoot /var/www/html
# Custom log file locations
LogLevel warn
ErrorLog /var/log/apache2/error-lae-laeweb.com.log
CustomLog /var/log/apache2/access-lae-laeweb.com.log combined
#ServerName www.lae-laeweb.com
ProxyRequests On
ProxyPass / http://lae-laeweb.com:8080/LAEWeb/ keepalive=on ttl=60
ProxyPassReverse / http://lae-laeweb.com:8080/LAEWeb/
<Location />
Order allow,deny
Allow from all
</Location>
</VirtualHost>
This is a script I use after uploading a new .war file for my web app to tomcat:
#!/bin/bash
cd ../usr/local/apache-tomcat-8.5.23/bin
./shutdown.sh
./startup.sh
cd ../../../..
service apache2 reload
service apache2 restart
service=apache2
if (( $(ps -ef | grep -v grep | grep $service | wc -l) > 0 ))
then
echo "$service is running!!!"
else
/etc/init.d/$service restart
fi
server.xml for tomcat:
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
<GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources>
<Service name="Catalina">
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="60000"
redirectPort="8443"
maxThreads="200" acceptCount="100" />
<!-- Define an AJP 1.3 Connector on port 8009 -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" connectionTimeout="60000" />
<Engine name="Catalina" defaultHost="lae-laeweb.com:8080">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<Host name="lae-laeweb.com" appBase="webapps" unpackWARs="true" autoDeploy="true">
<Alias>www.lae-laeweb.com</Alias>
<Context path="" docBase="/usr/local/apache-tomcat-8.5.23/webapps/LAEWeb" debug="0" privileged="true" reloadable="true" />
<Valve className="org.apache.catalina.valves.AccessLogValve"
directory="logs" prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t "%r" %s %b" resolveHosts="false" />
</Host>
</Engine>
</Service>
</Server>