将HTTP请求重定向到https的wildfly 10

问题描述 投票:6回答:3

这是我的独立,full.xml配置使用SSL配置 安全领域。

      <security-realm name="SslRealm">
            <server-identities>
            <ssl>
            <keystore path="D:\ncm.keystore" alias="ncm" keystore-password="*****" />
            </ssl>
            </server-identities>
        </security-realm>

子系统

 <server name="default-server">
            <http-listener name="default" socket-binding="http" redirect-socket="https"/>
            <https-listener name="default-ssl" socket-binding="https" security-realm="SslRealm"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <filter-ref name="server-header"/>
                <filter-ref name="x-powered-by-header"/>
            </host>
        </server>

套接字绑定

   <socket-binding name="http" port="${jboss.http.port:8080}"/>
    <socket-binding name="https" port="${jboss.https.port:8443}"/>

如何重定向到https:///localhost:8443/myApp当用户点击http://localhost:8080/myApp

spring ssl https jboss wildfly-10
3个回答
19
投票

重写规则可以用来重定向用户。在暗流子系统(standalone.xml或domain.xml中),你需要创建一个新的重写过滤器,然后启用一个新的fitler-REF过滤器:

创建过滤器部分中的新重写过滤器。在下面的例子中,用户将被重定向到https://myhostname:443/my-app。 %U为原始请求URL路径的占位符;要使用%U,使重定向友好,使用户的原始请求URL路径。

<filters>
<rewrite name="http-to-https" redirect="true" target="https://myhostname:8443%U"/>
</filters>

然后,使过滤器和主机部分配置谓词。谓词是你什么配置重写过滤器适用。在下面的例子中,我们重写过滤器只适用于请求将8080端口。

    <server name="default-server">
        <host name="default-host" alias="localhost">
            ...
            <filter-ref name="http-to-https" predicate="equals(%p,8080)"/>

下面是上述相同的配置改变了JBoss CLI步骤:

/subsystem=undertow/configuration=filter/rewrite=http-to-https:add(redirect="true",target="https://myhostname:8443%U")
/subsystem=undertow/server=default-server/host=default-host/filter-ref=http-to-https:add(predicate="equals(%p,8080)")

0
投票

我试过了

<rewrite name="http-to-https" redirect="true" target="https://my.website.com:443/Web/"/>

你可以不看%U

这一切HTTP流量重定向到HTTPS


0
投票

由于WildFly 15:管理控制台 - >网络 - >过滤器 - >添加重写规则https://%v%U

然后把它添加到您希望与条件equals(%p,80)每台主机。

无需创建每个主机的规则。

https://javagc.leponceau.org/2019/02/configuring-wildfly-to-redirect-https.html

© www.soinside.com 2019 - 2024. All rights reserved.