tomcat 配置域名和ssl证书
在tomcat上配置域名和ssl證書,記錄一下;
環(huán)境:
阿里云ECS CentOS 6.9
GeoTrust DV 證書
tomcat 7.0.92
?
1、在阿里云 域名解析 控制臺,配置域名DNS解析;
比如:二級域名為? test.com
主機(jī)記錄:www? ? ? ?( 即為 www.test.com )
記錄值:綁定的IPV4地址
其他默認(rèn);
2、在阿里云 SSL證書 控制臺,下載證書文件,tomcat下包含pfx文件、秘鑰pfx-password.txt文件;
服務(wù)器類型選擇Tomcat,點(diǎn)擊下載,壓縮包中包含 xxxxx__test.com.pfx, pfx-password.txt;
3、在tomcat根目錄,創(chuàng)建cert目錄,存放以上下載的兩個文件
比如:./cert/test.com.pfx
? ? ? ? ? ./cert/pfx-password.txt
4、在./cert/web.xml文件中,web-app節(jié)點(diǎn),添加如下內(nèi)容:
<security-constraint>
?? ?<web-resource-collection>
?? ??? ?<web-resource-name>SSL</web-resource-name>
?? ? ? ?<url-pattern>/*</url-pattern>
?? ?</web-resource-collection>
?? ?<user-data-constraint>
?? ??? ?<transport-guarantee>CONFIDENTIAL</transport-guarantee>
?? ?</user-data-constraint>
</security-constraint>
5、在./cert/server.xml文件中
5.1、80端口需要備案,可以使用http 8099端口先做測試;
在Service節(jié)點(diǎn),添加如下內(nèi)容,訪問 http 8099端口,會自動跳轉(zhuǎn)到 https 443 端口
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?比如:http://www.test.com:8099? ?=》? https://www.test.com
? ? <Connector port="8099" protocol="HTTP/1.1"
? ? ? ? ? ? ? ?connectionTimeout="20000"
? ? ? ? ? ? ? ?redirectPort="443" />
5.2、配置SSL證書和域名
在Service節(jié)點(diǎn),添加如下內(nèi)容,
? ? <Connector port="443" ?
? ? ? ? ? protocol="org.apache.coyote.http11.Http11Protocol" ?
? ? ? ? ? SSLEnabled="true" ?
? ? ? ? ? scheme="https" ?
? ? ? ? ? secure="true" ?
? ? ? ? ? keystoreFile="cert/test.com.pfx" ?
? ? ? ? ? keystoreType="PKCS12" ?
? ? ? ? ? keystorePass="xxxxxxxx"? ? ? ? ? ?==》pfx-password.txt文件中的秘鑰
? ? ? ? ? clientAuth="false" ?
? ? ? ? ? SSLProtocol="TLSv1+TLSv1.1+TLSv1.2" ?
? ? ? ? ? ciphers="TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_128_CBC_SHA256,TLS_RSA_WITH_AES_256_CBC_SHA256" />?
?
修改如下內(nèi)容:
? ? <!-- Define an AJP 1.3 Connector on port 8009 -->
? ? <Connector port="8009" protocol="AJP/1.3" redirectPort="443" />
?
? ? <!-- You should set jvmRoute to support load-balancing via AJP ie :
? ? <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">
? ? -->
? ? <Engine name="Catalina" defaultHost="www.test.com">
? ? ? <!--For clustering, please take a look at documentation at:
? ? ? ? ? /docs/cluster-howto.html ?(simple how to)
? ? ? ? ? /docs/config/cluster.html (reference documentation) -->
? ? ? <!--
? ? ? <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
? ? ? -->
? ? ? <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack -->
? ? ? <Realm className="org.apache.catalina.realm.LockOutRealm">
? ? ? ? <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". ?
? ? ? ? ? ? ? Any edits?that are performed against this UserDatabase are immediately available for use by the Realm. ?-->
? ? ? ? <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
? ? ? </Realm>
? ? ? <Host name="www.test.com" ?appBase="webapps" unpackWARs="true" autoDeploy="true">
? ? ? ? <!-- SingleSignOn valve, share authentication between web applications
? ? ? ? ? ? ?Documentation at: /docs/config/valve.html -->
? ? ? ? <!--
? ? ? ? <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
? ? ? ? -->
? ? ? ? <!-- Access log processes all example.
? ? ? ? ? ? ?Documentation at: /docs/config/valve.html
? ? ? ? ? ? ?Note: The pattern used is equivalent to using pattern="common" -->
? ? ? ? <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>
?
配置結(jié)束,啟動tomcat服務(wù);
測試地址:https://www.test.com
? ??
總結(jié)
以上是生活随笔為你收集整理的tomcat 配置域名和ssl证书的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 使用canvas绘制水滴(二次贝塞尔曲线
- 下一篇: 静态变量和静态方法编程训练—信用卡消费记