本文主要是介绍Tomcat8配置HTTPS,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
直接看配置,多余的注释都已经删除了
server.xml
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN"><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 --><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" /><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"/>--><!-- A "Connector" using the shared thread pool--><!--这部分可以直接注释掉,直接访问443端口--><!--<Connector executor="tomcatThreadPool"port="8080" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" />--><!--这种方式不适用--><!--<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"maxThreads="150" SSLEnabled="true"><SSLHostConfig><Certificate certificateKeystoreFile="C:/apache-tomcat-8.5.66/conf/rsa.jks" certificateKeystorePassword="password" type="RSA" /></SSLHostConfig></Connector>--><!--采用这种方式--><Connector port="443" protocol="HTTP/1.1" sslProtocol="TLS" clientAuth="false" keystorePass="password" URIEncoding="UTF-8"connectionTimeout="20000"keystoreFile="C:\apache-tomcat-8.5.66\conf\rsa.jks" scheme="https" SSLEnabled="true" maxThreads="150"> </Connector><!-- Define an AJP 1.3 Connector on port 8009 --><Connector port="8010" protocol="AJP/1.3" redirectPort="443" secretRequired=""/><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"><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>
这篇关于Tomcat8配置HTTPS的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!