zoukankan      html  css  js  c++  java
  • 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.

    
    
  • 相关阅读:
    redis 用scan 代替keys 解决百万数据模糊查询超时问题
    集成spring-ldap
    IDEA报Unable to save settings: Failed to save settings. Please restart IntelliJ IDEA随后闪退
    struts2响应文件 struts2下载txt
    QRCodeUtil 二维码生成 解析 带图片与不带图片的二维码
    java 手机号正则表达式 截止2019年6月最新
    Java遍历Map对象的四种方式效率对比
    SpringCloud Alibaba系列(二) Nacos高可用和持久化
    SpringCloud Alibaba系列(二) Nacos配置中心-分类配置
    SpringCloud Alibaba系列(二) Nacos使用
  • 原文地址:https://www.cnblogs.com/greys/p/10881161.html
Copyright © 2011-2022 走看看