tomcat綁定兩個https域名

配置server.xml文件
域名訪問先修改爲80端口,而後是redirectPort爲443web

<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="443" />
配置SSL證書apache

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

<!--配置證書路徑,密碼-->
<SSLHostConfig hostName="www.xxxx1.com" caCertificateFile="cert/www.xxxx.com.pem">
<Certificate certificateKeystoreFile="cert/www.xxxx1.com.pfx"
certificateKeystoreType="PKCS12" certificateKeystorePassword="***" />
</SSLHostConfig>webapp

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

修改redirectPort爲443server

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

一個項目對應多個域名域名

<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>it

多個項目須要配置多個host,其中須要注意每一個host下默認項目訪問路徑io

<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>

相關文章
相關標籤/搜索