- 准备好多个域名,下载配置https需要的域名证书
- 在linux上的tomact配置https多域名多项目
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8005" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<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">
<!-- 端口号 -->
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
<!-- 配置需要https的域名 -->
<!-- defaultSSLHostConfigName 默认域名 -->
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true" maxThreads="150" URIEncoding="UTF-8" defaultSSLHostConfigName="xxx.xxx.com">
<!-- hostName 域名 caCertificateFile 证书pem文件路径 certificateKeystoreFile 证书pfx文件路径 certificateKeystorePassword 证书密码 certificateKeystoreType 证书加密方式-->
<SSLHostConfig hostName="xxx.xxx.com" caCertificateFile="/root/shenda-cert/1593949_xxx.xxx.com.pem">
<Certificate certificateKeystoreFile="/root/shenda-cert/1593949_xxx.xxx.com.pfx" certificateKeystorePassword="Vgiy7gWD" certificateKeystoreType = "PKCS12"/>
</SSLHostConfig>
<SSLHostConfig hostName="xx.xx.com" caCertificateFile="/root/shenda-cert/1652623_xx.xx.com.pem">
<Certificate certificateKeystoreFile="/root/shenda-cert/1652623_xx.xx.com.pfx" certificateKeystorePassword="dqHFJyyq" certificateKeystoreType = "PKCS12"/>
</SSLHostConfig>
<SSLHostConfig hostName="x.x.com" caCertificateFile="/root/cert/1763811_x.x.com.pem">
<Certificate certificateKeystoreFile="/root/cert/1763811_x.x.com.pfx" certificateKeystorePassword="DyA5lTm7" certificateKeystoreType = "PKCS12"/>
</SSLHostConfig>
</Connector>
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
<!-- defaultHost 默认域名 -->
<Engine name="Catalina" defaultHost="xxx.xxx.com">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<!-- 第一个https域名的访问配置 -->
<!-- name 域名 appBase tomact启动后解析的根目录 -->
<Host name="xxx.xxx.com" appBase="/root/baoyuanerapp"
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" />
<!-- docBase 默认访问的项目具体路径 -->
<Context path="" docBase="/root/baoyuanerapp/ROOT" debug="0" reloadable="true" />
</Host>
<!-- 第二个https域名的访问配置 -->
<Host name="xx.xx.com" appBase="/root/baoyuaner_applet"
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" />
<Context path="" docBase="/root/baoyuaner_applet/ROOT" debug="0" reloadable="true" />
</Host>
<!-- 第三个https域名的访问配置 -->
<Host name="x.x.com" appBase="/root/ast/doctor"
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" />
<Context path="" docBase="/root/ast/doctor/doctor" debug="0" reloadable="true" />
</Host>
<!-- http的域名配置 -->
<Host name="vvv.vvv.com" appBase="/root/ast/nurse"
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" />
<!-- Context 若是不配置(注释)默认访问 appBase 下的项目-->
<Context path="" docBase="/root/ast/nurse/nurse" debug="0" reloadable="true" />
</Host>
</Engine>
</Service>
</Server>
- 在Windows上的tomcat配置单https
<?xml version="1.0" encoding="UTF-8"?>
<Server port="8014" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<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">
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443"
URIEncoding="UTF-8"/>
<!-- https配置 -->
<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true" maxThreads="150" URIEncoding="UTF-8" defaultSSLHostConfigName="xxx.xxx.com">
<SSLHostConfig hostName="xxx.xxx.com" caCertificateFile="C:\apache\conf\cert\214966939770875.pem">
<Certificate certificateKeystoreFile="C:\apache\conf\cert\214966939770875.pfx" certificateKeystorePassword="214966939770875" certificateKeystoreType = "PKCS12"/>
</SSLHostConfig>
</Connector>
<Connector port="8015" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="www.dyxingfu.com">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm>
<!-- 域名配置 -->
<Host name="xxx.xxx.com" appBase="C:\apache\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" />
<Context docBase="C:\apache\webapps\ROOT" path="" debug="0" reloadable="true"/>
</Host>
<Host name="xx.xx.com" appBase="C:\admin_business"
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" />
<!-- <Context path="" docBase="C:\admin_business\ROOT" debug="0" reloadable="true" /> -->
</Host>
</Engine>
</Service>
</Server>
网友评论