HTTPS configuration and HTTP auto-jump configuration for Tomcat

Source: Internet
Author: User

1. Generate a Certificate

(1) Open Keytool.exe under the JDK's installation directory \bin\keytool.exe

      

On the command line, enter the following command:

Keytool-genkeypair-alias "Tomcat"-keyalg "RSA"-keystore "E:\tomcat.keystore"-validity 36500

  

The above command will produce a pair of asymmetric keys and self-signed certificates E:\tomcat.keystore

Note: "First and last name" should be the domain name, lost to the name, and the real run time domain name does not match, will be problematic

Here I enter the password is 123456, the domain name is tomcat for example, provinces and cities in Guangdong Shenzhen as an example

Configuring the Tomcat server

Locate the installation directory for the Tomcat server and locate the Server.xml file under Conf

Find the following code that has been commented:

<!--<connector port="8443"Protocol="http/1.1"Sslenabled="true"   
maxthreads=" Max"Scheme="HTTPS"Secure="true"Clientauth="false"Sslprotocol="TLS"/>
-

Remove the comment and modify it to:

<connector port="8443"Protocol="http/1.1"Sslenabled="true"MaxThreads=" Max"Scheme="HTTPS"Secure="true"ClientAuth="false"Sslprotocol="TLS"Keystorefile="E:\tomcat.keystore"Keystorepass="123456"/>

On the Internet, the default port for the HTTP protocol is 443, and the default port for HTTPS is 443.

3.HTTP Automatic Jump Configuration

Configure Tomcat, open $CATALINA _home/conf/server.xml, and modify the following

<connector port="8080" protocol="http/1.1"                ConnectionTimeout="20000"               redirectport="  8443" />

Revision changed to

 <connector port= " 80  "  protocol= " http/1.1   "  connectiontimeout  = " 20000  "   Redirectport  = " 443  " /> 
<!--   <connector port="8009" enablelookups="false" protocol="ajp/1.3" redirectport="8443" />-- >

Modified to:

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

Add such a section to the </welcome-file-list> behind the Tomcat\conf\web.xml

    <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 configuration and HTTP auto-jump configuration for Tomcat

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.