配置server.xml文件 域名访问先修改成80端口,然后是redirectPort为443

<Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" /> 配置SSL证书

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol" maxThreads="150" SSLEnabled="true" URIEncoding="UTF-8" defaultSSLHostConfigName="www.xxxx.com">

<!--配置证书路径,密码--> <SSLHostConfig hostName="www.xxxx1.com" caCertificateFile="cert/www.xxxx.com.pem"> <Certificate certificateKeystoreFile="cert/www.xxxx1.com.pfx" certificateKeystoreType="PKCS12" certificateKeystorePassword="***" /> </SSLHostConfig>

<SSLHostConfig hostName="www.xxx2.com" caCertificateFile="cert/www.xxxx2.com.pem"> <Certificate certificateKeystoreFile="cert/www.xxxx2.com.pfx" certificateKeystoreType="PKCS12" certificateKeystorePassword="***" /> </SSLHostConfig> </Connector>

修改redirectPort为443

<!-- Define an AJP 1.3 Connector on port 8009 --> <Connector port="8009" protocol="AJP/1.3" redirectPort="443" />

一个项目对应多个域名

<Host name="www.xxxx1.com" appBase="webapps" unpackWARs="false" autoDeploy="true" defaultHost="www.xxxx1.com"> <!--多个域名别名--> <Alias>www.xxx1.com</Alias> <Alias>www.xxxx2.com</Alias> <!--默认项目访问路径--> <Context path="" docBase="项目地址" reloadable="false" /> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host>

多个项目需要配置多个host,其中需要注意每个host下默认项目访问路径

<Engine name="Catalina" defaultHost="www.xxxxx1.com"> <Host name="xxxxx1.com" appBase="webapps" unpackWARs="true" autoDeploy="true"> <!--默认项目访问路径--> <Context path="" docBase="项目地址" reloadable="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>

<Host name="www.xxxxxx2.com" appBase="项目地址" unpackWARs="true" autoDeploy="true"> <!--默认项目访问路径--> <Context path="" docBase="project2" reloadable="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>