将http重定向到https无效

时间:2015-08-19 10:14:28

标签: maven

我想将Http重定向到Https。因此,我使用&key; #tokey -genkey -alias mydomain -keyalg RSA -keystore keystore.jks -storepass password'创建了一个证书。这个命令。

的pom.xml

 <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>2.0</version>
            <configuration>
                <warSourceDirectory>${webappDirectory}</warSourceDirectory>
                <path>bigdata</path>
                <stopPort>9966</stopPort>
                <stopKey>foo</stopKey>
                <httpsPort>8443</httpsPort>
                <keystoreFile>/usr/local/Keystorefiles/keystore.jks</keystoreFile>
                <keystorePass>arya123</keystorePass>
                <password>arya123</password>
            </configuration>
        </plugin>

的web.xml

<security-constraint>
<web-resource-collection>
<web-resource-name>securedapp</web-resource-name>
<url-pattern>/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>

的Server.xml

<?xml version="1.0" encoding="UTF-8"?>
<Server address="localhost" port="8005" shutdown="SHUTDOWN">
  <Listener className="org.apache.catalina.core.JasperListener"/>
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener"/>
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener"/>
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener"/>
  <GlobalNamingResources>
      <Resource auth="Container" description="User database  that        can    be  updated and saved" factory="org.apache.catalina.users.MemoryUserDatabaseFactory"  name="UserDatabase" pathname="conf/tomcat-users.xml"  type="org.apache.catalina.UserDatabase"/>
  </GlobalNamingResources>
  <Service name="Catalina">
   <Connector address="dt" connectionTimeout="20000" port="8080"  protocol="HTTP/1.1" redirectPort="8443"/>
      <!-- <Connector executor="tomcatThreadPool"
           port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000" redirectPort="8443" />-->
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
           maxThreads="150" scheme="https" secure="true"
           clientAuth="false" sslProtocol="TLS"
    keystoreFile="/usr/local/Keystorefiles/keystore.jks"
           keystorePass="arya123" />

 <Connector port="8009" protocol="AJP/1.3" redirectPort="8443"/>
 <Engine defaultHost="dt" name="Catalina">
 <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/>
  </Realm>
 <Host appBase="webapps" autoDeploy="true" name="dt" unpackWARs="true">
  <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" pattern="%h %l %u %t &quot;%r&quot; %s %b" prefix="localhost_access_log." suffix=".txt"/>

  <Context docBase="HelloWeb" path="/HelloWeb" reloadable="true" source="org.eclipse.jst.jee.server:HelloWeb"/><Context docBase="SpringMVCExample" path="/SpringMVCExample" reloadable="true" source="org.eclipse.jst.jee.server:SpringMVCExample"/><Context docBase="TrialApp" path="/TrialApp" reloadable="true" source="org.eclipse.jst.jee.server:TrialApp"/><Context docBase="ABDFver3" path="/bigdata" reloadable="true" source="org.eclipse.jst.jee.server:ABDFver3"/></Host>
</Engine>
</Service>
 </Server>

我做了很多。但是当我提供URL时,它不会重定向到Https。有谁可以帮助我?

1 个答案:

答案 0 :(得分:0)

我假设您不想手动执行' redirect-thing '。通常这是由服务器为您完成的 - 这就是为什么您不必在应用程序中编辑设置而在服务器上编辑设置的原因!

可以在此处找到Tomcat的许多教程之一:https://www.mulesoft.com/tcat/tomcat-ssl