tomcat配置https


http訪問tomcat默認端口是80,http://域名
https訪問tomcat 的端口是443,https://域名
https訪問tomcat的8443端口就相當於http訪問tomcat的8080端口,需要在域名后面拼接端口號,http://域名:8080,https://域名:8443。

server.xml配置如下。

1、<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" />
2、<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true" maxThreads="150" scheme="https" secure="true" clientAuth="false" sslProtocol="TLS" keystoreFile="C:/soft/tomcat.keystore" keystorePass="123456"/>
3、<Connector port="8009" enableLookups="false" protocol="AJP/1.3" redirectPort="443" />
上面的443是由原本的8443修改的,因為443(https)相當於80(http)的端口。其中2在http訪問的下是被注釋掉的,而在https才可以使用。

web.xml的配置如下

在web.xml文件的倒數第二行(</welcome-file-list>下面)添加如下配置。

<login-config>
<!-- Authorization setting for SSL -->

<auth-method>CLIENT-CERT</auth-method>

<realm-name>Client Cert Users-only Area</realm-name>
</login-config>

<security-constraint>
<!-- Authorization setting for SSL -->

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

參考地址:https://www.cnblogs.com/luchangyou/p/6028067.html


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM