tomcat下配置http和https

 

 以下配置文件中配置了多个connector,采用https443和http80端口。8009是AJP的端口,如果没有用到jsp,可以将这个注释。

<?xml version='1.0' encoding='utf-8'?>
<Server port="8008" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
  
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
  <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />

  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <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">

    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-"  maxThreads="150" minSpareThreads="4"/>
    
    <Connector port="80" protocol="HTTP/1.1"  connectionTimeout="20000"  redirectPort="443" minProcessors="5" maxProcessors="75" executor="tomcatThreadPool"/>
    
    <Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="443"  minProcessors="5" maxProcessors="75" executor="tomcatThreadPool"/>
    
    <Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" scheme="https" secure="true"  minProcessors="5" maxProcessors="75" 
     clientAuth="false" sslProtocol="TLS" keystoreFile="cert/2216814_https.xxxxxx.com.pfx" keystorePass="Fa5oLIfT" executor="tomcatThreadPool"/>
   
    <Engine name="Catalina" defaultHost="localhost">

      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
      </Realm>

      <Host name="localhost"  appBase="webapps" unpackWARs="true" autoDeploy="true">
      </Host>
    </Engine>
  </Service>
</Server>
注:
  上述autoDeploy="true" 可以改为false;
   tomcatThreadPool可以不配,建议配上,用线程池管理以省去线程创建和销毁的时间

web.xml

 

以上配置都是tomcat/conf下的文件 server.xml以及web.xml.


posted @ 2019-05-17 14:30  Greys  阅读(940)  评论(0编辑  收藏  举报