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>
  • 相关阅读:
    Mysql 设置变量的几种方式
    Mysql Alter table 操作
    Truncate有外键约束的表
    Mysql ESCAPE 用法
    Jquery checkbox operation
    Mysql 根据URL获取顶级域名
    MySQL分区表操作
    TIB工作室动态今后将发布在 http://www.automationqa.com/ , 敬请关注!
    TestPartner资源列表
    如何开始学习一个自动化测试工具?
  • 原文地址:https://www.cnblogs.com/pluto-yang/p/10429655.html
Copyright © 2011-2022 走看看