如何在JBoss EAP 6.4中将http重定向到https?

时间:2017-05-12 09:08:11

标签: amazon-web-services ssl redirect jboss-eap-6

此处如何将替换设置为任何地址,以便我可以在AWS Application Load Balancer中使用它。

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https"  enable-lookups="false" secure="true" />
<virtual-server name="default-host" enable-welcome-root="true">
    <rewrite pattern="^/(.*)$" substitution="https://localhost:443/$1" flags="RL">
        <condition test="%{HTTPS}" pattern="off" />
    </rewrite>               
    <alias name="localhost"/>
    <alias name="example.com"/>
</virtual-server>

我想要

<rewrite pattern="^/(.*)$" substitution="https://%HOST_NAME%" flags="RL">
    <condition test="%{HTTPS}" pattern="off" />
</rewrite>

2 个答案:

答案 0 :(得分:0)

以下是在EAP 6中从http重定向到https的步骤,

redirect-port =“443”添加到 http连接器,如下所示:

<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" redirect-port="443"/>

将https的套接字绑定更改为443,如下所示:

<socket-binding name="https" port="443"/>

在EAP 6中配置https连接器

 <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
                <ssl name="ssl" key-alias="mykey" password="password" certificate-key-file="/path/to/keystore.jks"/>
        </connector>

编辑应用程序的web.xml,如下所示: -

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

    </web-app>

答案 1 :(得分:0)

这对我有用(更改configruation / standalone-full.xml):

        <filters>
            <rewrite name="http-to-https" target="https://${jboss.qualified.host.name}:8443%U" redirect="true"/>
        </filters>