tomcat配置多个ssl证书
下载 ssl 证书就不说了,只看 server.xml 配置
<?xml version="1.0" encoding="UTF-8"?>
<!-- 访问 80 重定向到 443 --> <Connector port="80" maxHttpHeaderSize="8192" address="0.0.0.0" maxThreads="150" minSpareThreads="25" maxSpareThreads="75" enableLookups="false" redirectPort="443" acceptCount="100" connectionTimeout="20000" disableUploadTimeout="true" />
<!-- 特别注意 defaultSSLHostConfigName 要配置一个默认的访问域名 --> <Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" defaultSSLHostConfigName="www.test.a.com"> <SSLHostConfig hostName="www.test.a.com"> <Certificate certificateKeystoreFile="D:\tomcat\apache-tomcat-8.5.20\cert\1\a.pfx" certificateKeystorePassword="a的密码" certificateKeystoreType="PKCS12" /> </SSLHostConfig> <SSLHostConfig hostName="www.test.b.com"> <Certificate certificateKeystoreFile="D:\tomcat\apache-tomcat-8.5.20\cert\2\b.pfx" certificateKeystorePassword="b的密码" certificateKeystoreType="PKCS12" /> </SSLHostConfig> </Connector> <Connector port="8009" protocol="AJP/1.3" redirectPort="443" /> <Engine name="Catalina" defaultHost="www.test.a.com"> <Realm className="org.apache.catalina.realm.LockOutRealm"> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm>
<!-- 这里配置的两个域名访问的是同一个 项目 --> <Host name="www.test.a.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Alias>www.test.a.com</Alias> <Alias>www.test.b.com</Alias> <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>
只要你不觉得尴尬,那尴尬的就是别人