Tomcat8.5 server configuration Https protocol SSL certificate and automatically jump to Http Https

I use the cloud server and Ali free certificate (poor

We first need to Ali cloud management console to download the SSL certificate SSL certificate

Here Insert Picture Description
Next up is this:
Here Insert Picture Description

Then the certificate pfx copy of the file suffix to tomcat/conf/certthe directory

It can also be copied to tomcat/certthe same time you can look at their own preferences as long as the fill path configuration
Note : Just copy pfx file
cert default directory does not exist need to create
to create a pass over the pfx file up to

Then modify the server's server.xmlfile

Note: This is Tomcat8.5 version of the configuration Tomcat7 version of the profile is not the same as if not the same Tomcat8

path:Tomcat安装目录/conf/server.xml

Step one: Navigate to <Connector port="80"”
configure the default port
read:

<!-- 配置默认端口  -->
 <Connector port="80" protocol="HTTP/1.1"
   connectionTimeout="20000"
    redirectPort="443" />

The second step: Repositioning to the <Connector port="8443"
connection port 443 configured
to:

<Connector port="443" protocol="org.apache.coyote.http11.Http11NioProtocol"
       SSLEnabled="true" >
   <SSLHostConfig>                            <!--证书文件所在的目录  -->                             
        <Certificate certificateKeystoreFile="conf/cert/*****.pfx" 
                     certificateKeystoreType="PKCS12" certificateKeystorePassword="密码" /> 
    </SSLHostConfig>
</Connector>

The final step: Repositioning to <Connector port="8009"
configure the default port forwarding
to read:

<!--默认转发端口-->
<!-- <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> -->
<Connector port="8009" protocol="AJP/1.3" redirectPort="443" />

If Ali is the cloud, then remember to turn on the appropriate permissions set otherwise it will be blocked access not lead to Ali goes
Here Insert Picture Description
perfect!
This is done? Yet
this is the case but still be able to access the http protocol will be prompted to unsafe use

We also can automatically be converted to https to http

In conf/web.xmlthe configuration
bottommost added content as follows (if the delay does not turn in the end 99999j jump directly input lines directly in the end portion 99999):

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

Here Insert Picture Description

So you're done


Published 174 original articles · won praise 5 · Views 240,000 +

Guess you like

Origin blog.csdn.net/Piconjo/article/details/104929099