修改Tomcat主页和http变成https

配置Tomcat服务器 将访问http变成https的步骤

  1. 在腾讯云上申请一个SSL证书,申请证书的时候,要将密码填写上,否则不会产生出来Tomcat的文件。
  2. 将颁发的文件copy到Tomcat目录下的conf目录下
  3. 编辑server.xml文件

编辑server.xml 更改的地方

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

 <Connector port="443" protocol="HTTP/1.1" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="conf/www.qiqibl.com.jks"
keystorePass="huyande"
clientAuth="false" sslProtocol="TLS" />
  • 注意:将8080 改为80 ,将8443 改为443

编辑web.xml

到conf目录下的web.xml。在后面,,也就是倒数第二段里,加上这样一段

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

修改Tomcat主页

<Context path="" docBase="xiaoyuanfuwu" debug="0" reloadable="true" />
  • 注意:path 不填代表是虚拟目录的名称,如果是只输入ip地址就显示主页,该键值留空,
  • docBase:表示项目的目录的名称,需要在webapps目录下,创建一个这样的目录