Hướng dẫn cấu hình Tomcat chạy HTTP và HTTPS

Hướng dẫn cấu hình Tomcat chạy song song 2 port HTTP và HTTPS

Để cấu hình tomcat chạy chuyển hướng hoặc chạy song song http và https Quý khách có thể thay đổi trong 2 file web.xml và server.xml. Dưới đây là config để chạy song song

Cấu hình file: server.xml

    <Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           URIEncoding="UTF-8" 
           redirectPort="8443" />

    <Connector port="8443" protocol="HTTP/1.1" 
           SSLEnabled="true"
           scheme="https" 
           secure="true"
           Server=""
           keystoreFile="conf/.keystore"
           keystorePass="password"
           maxThreads="150"
           maxSpareThreads="75"
           minSpareThreads="25" 
           clientAuth="false" sslProtocol="TLS" 
           URIEncoding="UTF-8"
           />

Cấu hình file: web.xml

 <security-constraint>
<web-resource-collection>
<!-- <web-resource-name>HTTPSOnly</web-resource-name> -->
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<!-- <transport-guarantee>CONFIDENTIAL</transport-guarantee> -->
</user-data-constraint>
</security-constraint>

file này đã được chú thích 2 dòng chuyển hướng “<web-resource-name>HTTPSOnly</web-resource-name>” và <!-- <transport-guarantee>CONFIDENTIAL</transport-guarantee> -->

Trong trường hợp cần chuyển hướng http sang https quý khách có thể bỏ chú thích 2 dòng này

Published
Categorized as Email

By Nguyen Manh Cuong

Nguyen Manh Cuong is the author and founder of the nguyendiep blog. With over 14 years of experience in Online Marketing, he now runs a number of successful websites, and occasionally shares his experience & knowledge on this blog.

Leave a comment

Your email address will not be published. Required fields are marked *