http到https重定向(tomcat / jboss)

时间:2014-05-22 11:22:04

标签: java tomcat redirect https jboss

我们希望将来自应用程序http url的所有流量重定向到https,为此,我们在deploy / jboss-web.deployer / conf目录的web.xml中设置以下值。 / p>

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

这确实成功地将用户重定向到https位置但他们使用不同的端口来确定deploy / jboss-web.deployer路径中server.xml中配置的内容

<Connector port="8381" address="${jboss.bind.address}"    
         maxThreads="350" maxHttpHeaderSize="8192"
         emptySessionPath="true" protocol="HTTP/1.1"
         enableLookups="false" redirectPort="8543" acceptCount="100"
         connectionTimeout="20000" disableUploadTimeout="true" compression="on" />

    <!-- Define a SSL HTTP/1.1 Connector on port 8643
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!---->
    <Connector port="8543" protocol="HTTP/1.1" SSLEnabled="true"
            maxThreads="150" scheme="https" secure="true"
            clientAuth="false" sslProtocol="TLS"
            keystoreFile="${jboss.server.home.dir}/conf/localhost.keystore"
        keystorePass="changeit"
    />    

    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" address="${jboss.bind.address}" protocol="AJP/1.3"
         emptySessionPath="true" enableLookups="false" redirectPort="8543" />

      <Engine name="jboss.web" defaultHost="localhost" jvmRoute="data1">

我们将https端口设置为8543然后工作但是当用户转到http url时将用户重定向到的https端口是8744(当我们在server.xml中设置8744它成功运行时),但是我们找不到8744端口的位置,有没有人知道如何配置web.xml中第一个提到的代码重定向到哪个端口

另一个问题是,当我们将此配置投入生产时,https端口将是&#34; 443&#34;,我们需要知道在哪里设置443用于&#34;安全约束&#34;重定向到的条目。访问http://www.data.com必须重定向到https://www.data.com然后

此致 弥兰陀

1 个答案:

答案 0 :(得分:1)

好吧,好消息是,在生产中它会正常工作。安全约束正在完成其工作,但它被设计为仅在http(80)和https(443)之间工作。

注意8744 - 8381 = 363 = 443 - 80

我正在使用JBoss-4.2.3.GA并观察到相同的行为,不确定它是否仍然在Wildfly上执行此操作。