1. 程式人生 > >tomcat強制https訪問

tomcat強制https訪問

配置成功https訪問前提下,tomcat強制https訪問,web.xml

</welcome-file-list>後面

加入如下程式碼

<login-config>  
    <!-- Authorization setting for SSL -->  
   <auth-method>CLIENT-CERT</auth-method>  
    <realm-name>Client Cert Users-onlyArea</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>

如果訪問時 域名後面自動加上了8443埠 修改server.xml

<Connector port="80" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="443" maxHttpHeaderSize="8192"/>

redirectPort 改成443

<Connector port="443" 
	  	maxThreads="150"
		protocol="org.apache.coyote.http11.Http11Protocol"
                keystoreFile="cert/xxx.pfx"
		keystoreType="PKCS12"
		keystorePass="xxx"
		SSLEnabled="true" 
		scheme="https" 
		secure="true"
                clientAuth="false" 
		sslProtocol="TLS"

port 改成443

原文連結:https://www.wanpishe.top/article?blogId=524771bc-be0e-4c9b-9241-30b0c6b7b115