笔记参照网址:详情请跳转查看Tomcat配置https方式访问-CSDN博客
关于签名处理可以看:https://www.cnblogs.com/namejr/p/18206214
*\apache-tomcat-9.0.65\conf\server.xml
<!--
<Connector port="8080" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" />
-->
<Connector port="8080" protocol="org.apache.coyote.http11.Http11NioProtocol"
connectionTimeout="20000"
redirectPort="8443" URIEncoding="UTF-8" SSLEnabled="true" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="C:/Users/namejr/Desktop/20240717/namejr.keystore" keystorePass="namejr" />
conf/server.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. --> <!-- Note: A "Server" is not itself a "Container", so you may not define subcomponents such as "Valves" at this level. Documentation at /docs/config/server.html --> <Server port="8005" shutdown="SHUTDOWN"> <!-- 用于以日志形式输出服务器 、操作系统、JVM的版本信息 --> <Listener className="org.apache.catalina.startup.VersionLoggerListener" /> <!-- Security listener. Documentation at /docs/config/listeners.html <Listener className="org.apache.catalina.security.SecurityListener" /> --> <!-- APR library loader. Documentation at /docs/apr.html --> <!-- 用于加载(服务器启动)和销毁(服务器停止)APR。如果找不到APR库,则会输出日志,并不影响Tomcat启动 --> <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> <!-- Prevent memory leaks due to use of particular java/javax APIs--> <!-- 用于避免JRE内存泄漏问题 --> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> <!-- 用户加载(服务器启动) 和 销毁(服务器停止) 全局命名服务 --> <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> <!-- 用于在Context停止时重建Executor 池中的线程, 以避免ThreadLocal 相关的内存泄漏 --> <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <!-- Global JNDI resources Documentation at /docs/jndi-resources-howto.html --> <GlobalNamingResources> <!-- 可编辑的用户数据库,UserDatabaseRealm也可以使用该数据库对用户进行身份验证 --> <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> <!-- “服务”是一个或多个“连接器”的集合,它们共享一个“容器”。注意:“服务”本身并不是一个“容器”,因此您可能无法在此级别定义诸如“阀门”之类的子组件。 Documentation at /docs/config/service.html --> <Service name="Catalina"> <!-- 连接器可以使用共享执行器,您可以定义一个或多个命名线程池 --> <!-- <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" maxThreads="150" minSpareThreads="4"/> --> <!-- “连接器”表示一个端点,通过该端点接收请求并返回响应。文件地址: Java HTTP Connector: /docs/config/http.html Java AJP Connector: /docs/config/ajp.html APR (HTTP/AJP) Connector: /docs/apr.html Define a non-SSL/TLS HTTP/1.1 Connector on port 8080 --> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> <!-- 使用共享线程池的“连接器” --> <!-- <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" /> --> <!-- 在端口8443上定义一个SSL/TLS HTTP/1.1连接器,该连接器使用NIO实现。默认的ssl实现将取决于APR/本机库的存在和APR lifecyclelistener的useOpenSSL属性。无论选择哪种ssl实现,都可以使用JSSE或OpenSSL样式的配置。下面使用JSSE样式的配置。 --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true"> <SSLHostConfig> <Certificate certificateKeystoreFile="conf/localhost-rsa.jks" type="RSA" /> </SSLHostConfig> </Connector> --> <!-- 使用HTTP/2在端口8443上定义一个SSL/TLS HTTP/1.1连接器。该连接器使用APR/native实现,该实现始终为TLS使用OpenSSL。可以使用JSSE或OpenSSL样式的配置。下面使用OpenSSL样式的配置。 --> <!-- <Connector port="8443" protocol="org.apache.coyote.http11.Http11AprProtocol" maxThreads="150" SSLEnabled="true" > <UpgradeProtocol className="org.apache.coyote.http2.Http2Protocol" /> <SSLHostConfig> <Certificate certificateKeyFile="conf/localhost-rsa-key.pem" certificateFile="conf/localhost-rsa-cert.pem" certificateChainFile="conf/localhost-rsa-chain.pem" type="RSA" /> </SSLHostConfig> </Connector> --> <!-- 在端口8009上定义AJP 1.3连接器 --> <!-- <Connector protocol="AJP/1.3" address="::1" port="8009" redirectPort="8443" /> --> <!-- Engine表示处理每个请求的入口点(在Catalina中)。Tomcat的Engine实现单独分析请求中包含的HTTP头,并将它们传递给适当的主机(虚拟主机)。 Documentation at /docs/config/engine.html --> <!-- 你应该设置jvmrroute来支持通过AJP ie的负载均衡: <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> --> <Engine name="Catalina" defaultHost="localhost"> <!-- 对于集群,请查看以下文档: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- 使用LockOutRealm来防止通过暴力攻击猜测用户密码的尝试 --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- 这个领域使用在“UserDatabase”键下的全局JNDI资源中配置的UserDatabase。对这个UserDatabase执行的任何编辑都可以立即被Realm使用。 --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <!-- Host: name: 当前Host通用的网络名称, 必须与DNS服务器上的注册信息一致。 Engine中包含的Host必须存在一个名称与Engine的defaultHost设置一致。 appBase: 当前Host的应用基础目录, 当前Host上部署的Web应用均在该目录下(可以是绝对目录,相对路径)。默认为webapps。 unpackWARs: 设置为true, Host在启动时会将appBase目录下war包解压为目录。设置为 false, Host将直接从war文件启动。 autoDeploy: 控制tomcat是否在运行时定期检测并自动部署新增或变更的web应用。 --> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!-- SingleSignOn阀门,在web应用程序之间共享身份验证 Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- 访问日志进程的所有示例。 文档在: /docs/config/valve.html 注意:使用的模式相当于使用 pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine> </Service> </Server>
浙公网安备 33010602011771号