日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

tomcat 配置域名和ssl证书

發(fā)布時間:2024/1/8 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tomcat 配置域名和ssl证书 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

在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 &quot;%r&quot; %s %b" />

? ? ? </Host>
? ? </Engine>

?

配置結(jié)束,啟動tomcat服務(wù);

測試地址:https://www.test.com
? ??

總結(jié)

以上是生活随笔為你收集整理的tomcat 配置域名和ssl证书的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。