1. 设置https 访问:
修改server.xml
<Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS"
keystoreFile="/usr/share/tomcat7/conf/.keystore" keystorePass="sunyainfo.com"/>
keystoreFile : 证书存放路径
keystorePass : 证书密码
2.配置端口转发
修改server.xml,配置80端口,将8080改成80, redirectPort设置为443
<Connector port="80" protocol="HTTP/1.1"
connectionTimeout="20000"
URIEncoding="UTF-8"
redirectPort="443" />
3、修改WEB配置
conf/web.xml里最后面</welcome-file-list>标签后面
</web-app>标签前面如果不添加如下代码,http和https都可以访问,此时不会自动跳转。添加内容具体内容如下:
<login-config>
<!-- Authorization setting for SSL -->
<auth-method>CLIENT-CERT</auth-method><realm-name>Client Cert Users-only Area</realm-name>
</login-config>
<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>