首页 > 代码库 > Tomcat http跳转https

Tomcat http跳转https

由于输入域名某人使用http,为了使用户直接输入域名也能访问且使用https,做如下处理。


(ssl部署等这里暂不讨论)

1、在tomcat conf目录下修改配置文件server.xml:

<Connector port="8080" protocol="HTTP/1.1" 
            connectionTimeout="20000" 
              redirectPort="443" />   
              
 #将redirectPort="8443"修改为redirectPort="443"
 #其中由于防火墙上是80映射8080,所以这里不需要修改
 #443映射8443,所以下面8443端口也无需修改

2、在tomcat conf目录下修改配置文件web.xml:


   <welcome-file-list>
           <welcome-file>index.html</welcome-file>
           <welcome-file>index.htm</welcome-file>
           <welcome-file>index.jsp</welcome-file>   
           </welcome-file-list>
#在最后</welcome-file-list>后面加上以下语句:
<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>

3.重启tomcat,访问www.XXX.com,跳转为使用https访问



本文出自 “打怪升级” 博客,请务必保留此出处http://bilibili.blog.51cto.com/7121987/1931557

Tomcat http跳转https