zoukankan      html  css  js  c++  java
  • 通过tomcat把项目http请求转为https请求

    首先要明白的:https页面中不能使用http请求,http页面中可以使用https请求。

    如果项目上线后使用https访问,但是项目页面里的请求还有http,不需要修改代码,可通过修改tomcat的server.xml配置来强制把http请求替换成https请求

    tomcat的server.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <Server port="8005" shutdown="SHUTDOWN">
      <Listener className="org.apache.catalina.startup.VersionLoggerListener" />
      <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
      <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
      <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
      <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" />
    
      <GlobalNamingResources>
        <Resource name="UserDatabase" auth="Container"
                  type="org.apache.catalina.UserDatabase"
                  description="User database that can be updated and saved"
                  factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
                  pathname="conf/tomcat-users.xml" />
      </GlobalNamingResources>
    
      <Service name="Catalina">
        <!--http请求强制转为https的解决方案-->
        <Connector port="8080" protocol="HTTP/1.1"
                   proxyName="mkt.jw.jcfc.cn"
                   proxyPort="443"
                   scheme="https"
                   secure="true"
                   connectionTimeout="20000"
                   redirectPort="8443" />
        <!-- A "Connector" using the shared thread pool-->
        <!--
        <Connector executor="tomcatThreadPool"
                   port="8080" protocol="HTTP/1.1"
                   connectionTimeout="20000"
                   redirectPort="8443" />
        -->
        <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />
    
        <Engine name="Catalina" defaultHost="localhost">
          <Realm className="org.apache.catalina.realm.LockOutRealm">
            <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
                   resourceName="UserDatabase"/>
          </Realm>
    
          <Host name="localhost"  appBase="webapps"
                unpackWARs="true" autoDeploy="true">
            <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
                   prefix="localhost_access_log" suffix=".txt"
                   pattern="%h %l %u %t &quot;%r&quot; %s %b" />
          </Host>
        </Engine>
    
      </Service>
    </Server>
  • 相关阅读:
    特征方程
    鸽巢原理
    Python列表与字典
    布尔型
    python字符串
    Python小笔记
    IntelliJ 中Maven pom.xml依赖不生效解决
    IDEA创建servlet,篇末有找不到servlet报404的原因
    jQuery的ajax之验证用户名是否被注册
    jquery之Validata表单验证
  • 原文地址:https://www.cnblogs.com/pluto-yang/p/10429655.html
Copyright © 2011-2022 走看看