Tomcat https access settings

Source: Internet
Author: User

1> Use jdk to generate the key file
 
[Plain] view plaincopyprint?
Keytool-genkey-alias tomcat-keyalg RSA-keypass changeit-storepass changeit-keystore server. keystore-validity 3600
 
2> go to tomcat/config/server. xml and find
 
 
<! -- Define a ssl http/1.1 Connector on port 8443
This connector uses the JSSE configuration, when using APR,
Connector shocould be using the OpenSSL style configuration
Described in the APR documentation -->
<! --
<Connector port = "8443" protocol = "HTTP/1.1" SSLEnabled = "true"
MaxThreads = "150" scheme = "https" secure = "true"
ClientAuth = "false" sslProtocol = "TLS"/>
-->
Remove comments and add key file configuration
 
 
<Connector port = "8443" protocol = "HTTP/1.1" SSLEnabled = "true"
MaxThreads = "150" scheme = "https" secure = "true"
ClientAuth = "false" sslProtocol = "TLS"
KeystoreFile = "server. keystore"
KeystorePass = "changeit"/>
 
After saving and restarting tomcat, you can access tomcat through https: // ip: 8443/webproject (your web project) over https. Port 8443 is used above. If port 443 is changed to port, because 443 is the default https Port
 
 
Force https access
 
Add the following configuration after </welcome-file-list> in 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>
 
Enter http: // ip: 8080/webproject to force redirect to https: // ip: 8443/webproject.
 
 
If the https port is set to another port, remember to change the http transfer port together.
Www.2cto.com
 
<Connector port = "8080" protocol = "HTTP/1.1"
ConnectionTimeout = "20000"
RedirectPort = "<span style =" color: # FF0000; "> 8443 </span>" URIEncoding = "UTF-8"/>


Column of the author ChinFeng

Related Article

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.