我有一个托pipe在Ubuntu 16.04的非托pipeVPS服务器上的域我已经configuration了我的Java EE Tomcat Web应用程序在我的域名。 但是,应用程序的响应时间太慢,逐渐趋向于浏览器中的超时。 如果我停止apache2服务,并通过域名访问我的web应用程序:8080的web应用程序的性能是完美的。 你如何正确configurationapache2提供良好的性能的域名的tomcatnetworking应用程序? 我意识到,简单的解决scheme是链接到我的web应用程序的所有引用到域:8080,但我想知道如何正确configurationapache2提供的域名与Tomcat的web应用程序相同的性能使用域:8080 。 在此先感谢您的帮助。
这是我的apache2网站可用的文件的域名:
<VirtualHost *:80> # Admin email, Server Name (domain name) and any aliases ServerAdmin [email protected] 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>
这是我上传一个新的.war文件为我的web应用程序到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
tomcat的server.xml:
<?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>
当使用apache作为受networking延迟影响的代理时,应该调整缓冲以提高性能。 如文档中提供的 ,请尝试将其添加到您的虚拟主机文件中:
<VirtualHost *:80> ... ProxyRequests On ProxyReceiveBufferSize 512 ProxyPass / http://lae-laeweb.com:8080/LAEWeb/ keepalive=on ttl=60 ProxyPassReverse / http://lae-laeweb.com:8080/LAEWeb/ ...
正如文档中所build议的那样,避免缓冲区中的值低于512,并使用更高的值来查看是否最终获得更好的性能。 这里没有一个适合所有人的设置。
发现问题。 您必须在apache2 / sites-available文件夹的domain.conf文件中设置“ProxyRequests Off”。 现在一切正常。 感谢所有的海报。 非常感激。