将HTTP请求重定向到Wildfly 10中的https
这是我的standalone-full.xml配置,其中ssl配置了
security realm .
      <security-realm name="SslRealm">            <server-identities>
            <ssl>
            <keystore path="D:\ncm.keystore" alias="ncm" keystore-password="*****" />
            </ssl>
            </server-identities>
        </security-realm>
Subsystem
 <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
   <socket-binding name="http" port="${jboss.http.port:8080}"/>    <socket-binding name="https" port="${jboss.https.port:8443}"/>
回答:
重写规则可用于重定向用户。在undertow子系统(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)")
以上是 将HTTP请求重定向到Wildfly 10中的https 的全部内容, 来源链接: utcz.com/qa/418051.html



