tomcat 配置http跳转https
web.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>
server.xml配置https8443端口
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol" maxThreads="150" SSLEnabled="true" scheme="https" secure="true" keystoreFile="conf/keystore.jks" keystorePass="123456" clientAuth="false" sslProtocol="TLS" URIEncoding="UTF-8" />
然后redirectPort都指向8443
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="UTF-8" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
在使用IE11,tomcat6.0.20时,ie访问https端口会出现页面无法访问问题。可能是版本问题,换成tomcat7.0.94了就可以了。如有同类问题请参考。