将http请求重定向到wildfly 10中的https

编程入门 行业动态 更新时间:2024-10-24 14:17:50
本文介绍了将http请求重定向到wildfly 10中的https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是我的standalone-full.xml配置,配置了ssl 安全领域。

This is my standalone-full.xml configuration with ssl configured security realm .

<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

How to redirect to /localhost:8443/myApp when user hits localhost:8080/myApp

推荐答案

重写规则可用于重定向用户。在下层子系统(standalone.xml或domain.xml)中,您需要创建一个新的重写过滤器,然后在新的fitler-ref中启用过滤器:

A rewrite rule can be used to redirect users. In the undertow subsystem (standalone.xml or domain.xml) you will need to create a new rewrite filter and then enable the filter in a new fitler-ref:

创建过滤器部分中的新重写过滤器。在下面的示例中,用户将被重定向到 https:// myhostname:443 / my-app 。 %U是原始请求URL路径的占位符;您希望使用%U来使重定向友好并保留用户的原始请求网址路径。

Create the new rewrite filter in the filters section. In the example below, users will be redirected to myhostname:443/my-app. %U is a placeholder for the original request URL path; you want to use %U to make the redirect friendly and keep users' original request URL path.

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

然后,启用过滤器并在主机部分配置谓词。谓词是您配置重写过滤器适用的内容的位置。在下面的示例中,我们的重写过滤器仅适用于发往端口8080的请求。

Then, enable the filter and configure a predicate in the host section. The predicate is where you configure what the rewrite filter applies to. In the example below, our rewrite filter will only apply to requests going to port 8080.

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

以下是相同配置更改的JBoss CLI步骤:

Here are the JBoss CLI steps for the same configuration changes above:

/subsystem=undertow/configuration=filter/rewrite=http-to-https:add(redirect="true",target="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

本文发布于:2023-11-01 17:48:04,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1549995.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   http   wildfly   https

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!