Loading...

Tomcat配置http自动跳转至https

1、配置web.xml(和server.xml在同一目录下),在后面一部分添加如下一段话

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

配置后效果如下:

e1f08c34928b934c0e1f88a34b7e81e7.png

2、配置server.xml 即通过redirect实现http 8090端口自动跳转至https 8095端口

<Connector port="8090" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8095" URIEncoding="UTF-8"/>
<Connector port="8095" protocol="org.apache.coyote.http11.Http11NioProtocol"
				maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
				clientAuth="false"
				URIEncoding="UTF-8"
				sslEnabledProtocols="SSLv2,SSLv3,TLSv1,TLSv1.1,TLSv1.2,SSLv2Hello"
				keystoreFile="/app/wheelchair/ssl/server.keystore" keystorePass="passwd(keystore设置的密码)" />


0

回到顶部