记录tomcat配置https

匿名 (未验证) 提交于 2019-12-03 00:13:02

tomcat中配置https

在tomcat中的conf/server.xml中添加如下代码:

>Connector port="443" maxThreads="200" scheme="https" secure="true" SSLEnabled="true" keystoreFile="/usr/local/tomcat7/ssl/tomcat.keystore" keystorePass="123456" clientAuth="false" sslProtocol="TLS"/<

其中,keystoreFile是由crt和key生成的keyStore文件所在的路径,keystorePass是生成该文件时输入的密码。

tomcat配置http转https

修改server.xml,将80端口重定向到443端口:

>Connector port="80" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="443" /<

而后在web.xml最后添加如下代码(在之前):

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

然后访问http://domain.com及https://domain.com验证是否成功

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!