Tomcat to configure HTTPS and access HTTP to automatically jump to HTTPS

Source: Internet
Author: User

First, generate certificate step


Second, configure the Tomcat server

(1) Modify the $CATALINA _home/conf/server.xml file as follows:

<connector port= "protocol=" http/1.1 "connectiontimeout=" 20000 "redirectport=" 443 "executor=" TomcatThreadPoo L "enablelookups=" false "usebodyencodingforuri=" true "uriencoding=" Utf-8 "compression=" on "Compre Ssionminsize= "2048" nocompressionuseragents= "Gozilla,traviata" compressablemimetype= "Text/html,text/xml,text/jav Ascript,text/css,text/plain "/>

(2) Remove comments and modify parameters

<connector port= "443" protocol= "Org.apache.coyote.http11.Http11Protocol" sslenabled= "true" maxthreads= "150"      Scheme= "https" secure= "true" clientauth= "Want" sslprotocol= "TLS" keystorefile= "D:/tomcat.keystore" keystorepass= "123456" truststorefile= "D:/tomcat.keystore" truststorepass= "123456"/>

Note: Keystorefile, Keystorepass, Truststorefile, Truststorepass are the location and password of the certificate file, which are set during the certificate file generation process.

(3) Modifying parameters

<connector port= "8009" protocol= "ajp/1.3" redirectport= "443"/>

(4) Force HTTPS access: Open $catalina_home/conf/web.xml, or add the following to the Web. XML of the project file:

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

After the above configuration is complete, you can use SSL after rebooting tomcat. The IE Address bar can be entered directly into the address do not have to enter "http:/" or "https://", you can also enter "http://" Will jump to "https://" to log in.





Tomcat to configure HTTPS and access HTTP to automatically jump to HTTPS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.