


前面两篇文章我们讲了如图在centos下搭建tomcat环境及让tomcat支持ssl加密方法,这篇文章我们来讲下如何在访问时,强制将http跳转到https呢
centos下配置tomcat支持jsp方法:http://www.tag.gg/linux/11253.html
在tomcat配置ssl加密方法访问:http://www.tag.gg/linux/11254.html
将server.xml文件文件中的如下代码中的8443端口修改为443,并取消注释
<!– <Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”8443″ /> –>
改为:<Connector port=”8009″ protocol=”AJP/1.3″ redirectPort=”443″ />

然后打开conf下的web.xml文件,在</welcome-file-list>后面,</web-app>,也就是倒数第二段里添加如下代码即可:
- <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>

重启tomcat后测试输入http://tag.gg会调制跳转到http://tag.gg了
如有问题请在评论区留言哈,欢迎探讨



亲爱的:若该文章解决了您的问题,可否收藏+评论+分享呢?
文章评论 本文章有个评论